Completed
Branch master (0881bb)
by Michael
04:14
created
xoops_trust_path/libs/altsys/class/AltsysBreadcrumbs.class.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 class AltsysBreadcrumbs
5 5
 {
6 6
 
7
-    public $paths = array() ;
7
+    public $paths = array();
8 8
 
9 9
     public function AltsysBreadcrumbs()
10 10
     {
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
 //function &getInstance()
14 14
 public static function &getInstance()
15 15
 {
16
-    static $instance ;
17
-    if (! isset($instance)) {
18
-        $instance = new AltsysBreadcrumbs() ;
16
+    static $instance;
17
+    if (!isset($instance)) {
18
+        $instance = new AltsysBreadcrumbs();
19 19
     }
20
-    return $instance ;
20
+    return $instance;
21 21
 }
22 22
 
23 23
     public function getXoopsBreadcrumbs()
24 24
     {
25
-        $ret = array() ;
25
+        $ret = array();
26 26
         foreach ($this->paths as $val) {
27 27
             // delayed language constant
28 28
         if (substr($val['name'], 0, 1) == '_' && defined($val['name'])) {
29 29
             $ret[] = array(
30
-                'url' => $val['url'] ,
31
-                'name' => constant($val['name']) ,
32
-            ) ;
30
+                'url' => $val['url'],
31
+                'name' => constant($val['name']),
32
+            );
33 33
         } else {
34
-            $ret[] = $val ;
34
+            $ret[] = $val;
35 35
         }
36 36
         }
37
-        unset($ret[ sizeof($ret) - 1 ]['url']) ;
38
-        return $ret ;
37
+        unset($ret[sizeof($ret) - 1]['url']);
38
+        return $ret;
39 39
     }
40 40
 
41 41
 // all data should be escaped
@@ -44,19 +44,19 @@  discard block
 block discarded – undo
44 44
     if (is_array($url_or_path)) {
45 45
         if (empty($url_or_path['name'])) {
46 46
             // multiple paths
47
-            $this->paths = array_merge($this->paths, $url_or_path) ;
47
+            $this->paths = array_merge($this->paths, $url_or_path);
48 48
         } else {
49 49
             // array format (just a path)
50
-            $this->paths[] = $url_or_path ;
50
+            $this->paths[] = $url_or_path;
51 51
         }
52 52
     } else {
53 53
         // separate format
54
-        $this->paths[] = array( 'url' => $url_or_path , 'name' => $name ) ;
54
+        $this->paths[] = array('url' => $url_or_path, 'name' => $name);
55 55
     }
56 56
 }
57 57
 
58 58
     public function hasPaths()
59 59
     {
60
-        return ! empty($this->paths) ;
60
+        return !empty($this->paths);
61 61
     }
62 62
 }
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/class/altsysUtils.class.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     {
6 6
         $names = array();
7 7
         
8
-        if (! class_exists('XCube_Delegate')) {
8
+        if (!class_exists('XCube_Delegate')) {
9 9
             return $names;
10 10
         }
11 11
         
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
                 foreach (array_keys($callbacks) as $priority) {
24 24
                     foreach (array_keys($callbacks[$priority]) as $idx) {
25 25
                         $callback = $callbacks[$priority][$idx][0];
26
-                        $_name = (is_array($callback))? ((is_object($callback[0]))? get_class($callback[0]) : $callback[0]) : $callback;
26
+                        $_name = (is_array($callback)) ? ((is_object($callback[0])) ? get_class($callback[0]) : $callback[0]) : $callback;
27 27
                         $names[$priority] = $_name;
28 28
                     }
29 29
                 }
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
             $php523 = version_compare(PHP_VERSION, '5.2.3', '>=');
55 55
         }
56 56
         if (is_null($encoding)) {
57
-            $encoding = (defined('_CHARSET'))? _CHARSET : '';
57
+            $encoding = (defined('_CHARSET')) ? _CHARSET : '';
58 58
         }
59 59
         if ($php523) {
60 60
             return htmlspecialchars($str, $flags, $encoding, $double_encode);
61 61
         } else {
62 62
             $ret = htmlspecialchars($str, $flags, $encoding);
63
-            if (! $double_encode) {
63
+            if (!$double_encode) {
64 64
                 $ret = str_replace('&', '&', $ret);
65 65
             }
66 66
             return $ret;
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/class/SetupAltsysLangMgr.class.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! defined('XOOPS_ROOT_PATH')) {
4
-    exit ;
3
+if (!defined('XOOPS_ROOT_PATH')) {
4
+    exit;
5 5
 }
6 6
 
7
-if (! defined('XOOPS_TRUST_PATH') || XOOPS_TRUST_PATH == '') {
8
-    header('Location: '.XOOPS_URL.'/modules/altsys/setup_xoops_trust_path.php') ;
9
-    exit ;
7
+if (!defined('XOOPS_TRUST_PATH') || XOOPS_TRUST_PATH == '') {
8
+    header('Location: '.XOOPS_URL.'/modules/altsys/setup_xoops_trust_path.php');
9
+    exit;
10 10
 }
11 11
 
12
-define('ALTSYS_MYLANGUAGE_ROOT_PATH', XOOPS_ROOT_PATH . '/my_language');
12
+define('ALTSYS_MYLANGUAGE_ROOT_PATH', XOOPS_ROOT_PATH.'/my_language');
13 13
 
14 14
 
15 15
 class SetupAltsysLangMgr extends XCube_ActionFilter
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
 }
27 27
 
28 28
 
29
-require_once XOOPS_ROOT_PATH . "/core/XCube_LanguageManager.class.php";
30
-require_once XOOPS_ROOT_PATH . "/modules/legacy/kernel/Legacy_LanguageManager.class.php";
29
+require_once XOOPS_ROOT_PATH."/core/XCube_LanguageManager.class.php";
30
+require_once XOOPS_ROOT_PATH."/modules/legacy/kernel/Legacy_LanguageManager.class.php";
31 31
 
32 32
 class AltsysLangMgr_LanguageManager extends Legacy_LanguageManager
33 33
 {
34
-    public $langman = null ;
35
-    public $theme_lang_checked = false ;
34
+    public $langman = null;
35
+    public $theme_lang_checked = false;
36 36
 
37 37
     public function prepare()
38 38
     {
39
-        $langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php' ;
40
-        if (! file_exists($langmanpath)) {
41
-            die('install the latest altsys') ;
39
+        $langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php';
40
+        if (!file_exists($langmanpath)) {
41
+            die('install the latest altsys');
42 42
         }
43
-        require_once($langmanpath) ;
44
-        $this->langman =& D3LanguageManager::getInstance() ;
45
-        $this->langman->language = $this->mLanguageName ;
43
+        require_once($langmanpath);
44
+        $this->langman = & D3LanguageManager::getInstance();
45
+        $this->langman->language = $this->mLanguageName;
46 46
 
47 47
         parent::prepare();
48 48
     }
@@ -50,40 +50,40 @@  discard block
 block discarded – undo
50 50
     public function _loadLanguage($dirname, $fileBodyName)
51 51
     {
52 52
         // read/check once (selected_theme)/language/(lang).php
53
-        if (! $this->theme_lang_checked) {
54
-            $root =& XCube_Root::getSingleton() ;
55
-            if (! empty($root->mContext->mXoopsConfig['theme_set'])) {
56
-                $langdir = XOOPS_THEME_PATH.'/'.$root->mContext->mXoopsConfig['theme_set'].'/language' ;
53
+        if (!$this->theme_lang_checked) {
54
+            $root = & XCube_Root::getSingleton();
55
+            if (!empty($root->mContext->mXoopsConfig['theme_set'])) {
56
+                $langdir = XOOPS_THEME_PATH.'/'.$root->mContext->mXoopsConfig['theme_set'].'/language';
57 57
                 if (file_exists($langdir)) {
58
-                    $langfile = $langdir.'/'.$this->mLanguageName.'.php' ;
59
-                    $engfile = $langdir.'/english.php' ;
58
+                    $langfile = $langdir.'/'.$this->mLanguageName.'.php';
59
+                    $engfile = $langdir.'/english.php';
60 60
                     if (file_exists($langfile)) {
61
-                        require_once $langfile ;
61
+                        require_once $langfile;
62 62
                     } elseif (file_exists($engfile)) {
63
-                        require_once $engfile ;
63
+                        require_once $engfile;
64 64
                     }
65 65
                 }
66
-                $this->theme_lang_checked = true ;
66
+                $this->theme_lang_checked = true;
67 67
             }
68 68
         }
69 69
 
70 70
         // read normal
71
-        $this->langman->read($fileBodyName.'.php', $dirname) ;
71
+        $this->langman->read($fileBodyName.'.php', $dirname);
72 72
     }
73 73
 
74 74
     public function loadPageTypeMessageCatalog($type)
75 75
     {
76 76
         // I dare not to use langman...
77 77
         if (strpos($type, '.') === false && $this->langman->my_language) {
78
-            $mylang_file = $this->langman->my_language.'/'.$this->mLanguageName.'/'.$type.'.php' ;
78
+            $mylang_file = $this->langman->my_language.'/'.$this->mLanguageName.'/'.$type.'.php';
79 79
             if (file_exists($mylang_file)) {
80
-                require_once $mylang_file ;
80
+                require_once $mylang_file;
81 81
             }
82 82
         }
83
-        $original_error_level = error_reporting() ;
84
-        error_reporting($original_error_level & ~ E_NOTICE) ;
83
+        $original_error_level = error_reporting();
84
+        error_reporting($original_error_level & ~ E_NOTICE);
85 85
         parent::loadPageTypeMessageCatalog($type);
86
-        error_reporting($original_error_level) ;
86
+        error_reporting($original_error_level);
87 87
     }
88 88
 
89 89
     public function loadGlobalMessageCatalog()
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         /* if (!$this->_loadFile(XOOPS_ROOT_PATH . "/modules/legacy/language/" . $this->mLanguageName . "/global.php")) {
92 92
             $this->_loadFile(XOOPS_ROOT_PATH . "/modules/legacy/language/english/global.php");
93 93
         } */
94
-        $this->_loadLanguage('legacy', 'global') ;
94
+        $this->_loadLanguage('legacy', 'global');
95 95
 
96 96
         //
97 97
         // Now, if XOOPS_USE_MULTIBYTES isn't defined, set zero to it.
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/class/D3NotificationHandler.class.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 // notification handler for D3 modules
4 4
 
5
-require_once XOOPS_ROOT_PATH . '/include/notification_functions.php' ;
5
+require_once XOOPS_ROOT_PATH.'/include/notification_functions.php';
6 6
 
7 7
 class D3NotificationHandler
8 8
 {
@@ -10,68 +10,68 @@  discard block
 block discarded – undo
10 10
 //function &getInstance( $conn = null )
11 11
 public static function &getInstance($conn = null)
12 12
 {
13
-    static $instance ;
14
-    if (! isset($instance)) {
15
-        $instance = new D3NotificationHandler() ;
13
+    static $instance;
14
+    if (!isset($instance)) {
15
+        $instance = new D3NotificationHandler();
16 16
     }
17
-    return $instance ;
17
+    return $instance;
18 18
 }
19 19
 
20 20
 
21 21
     public function getMailTemplateDir($mydirname, $mytrustdirname = '')
22 22
     {
23
-        global $xoopsConfig ;
23
+        global $xoopsConfig;
24 24
 
25
-        $mydirpath = XOOPS_ROOT_PATH.'/modules/'.$mydirname ;
26
-        $mytrustdirpath = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname ;
27
-        $language = empty($xoopsConfig['language']) ? 'english' : $xoopsConfig['language'] ;
25
+        $mydirpath = XOOPS_ROOT_PATH.'/modules/'.$mydirname;
26
+        $mytrustdirpath = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname;
27
+        $language = empty($xoopsConfig['language']) ? 'english' : $xoopsConfig['language'];
28 28
 
29 29
         $search_paths = array(
30
-        "$mydirpath/language/$language/mail_template/" ,
31
-        "$mytrustdirpath/language/$language/mail_template/" ,
32
-        "$mydirpath/language/english/mail_template/" ,
33
-        "$mytrustdirpath/language/english/mail_template/" ,
34
-    ) ;
30
+        "$mydirpath/language/$language/mail_template/",
31
+        "$mytrustdirpath/language/$language/mail_template/",
32
+        "$mydirpath/language/english/mail_template/",
33
+        "$mytrustdirpath/language/english/mail_template/",
34
+    );
35 35
 
36
-        $mail_template_dir = "$mytrustdirpath/language/english/mail_template/" ;
36
+        $mail_template_dir = "$mytrustdirpath/language/english/mail_template/";
37 37
         foreach ($search_paths as $path) {
38 38
             if (file_exists($path)) {
39
-                $mail_template_dir = $path ;
40
-                break ;
39
+                $mail_template_dir = $path;
40
+                break;
41 41
             }
42 42
         }
43 43
 
44
-        return $mail_template_dir ;
44
+        return $mail_template_dir;
45 45
     }
46 46
 
47 47
 
48
-    public function triggerEvent($mydirname, $mytrustdirname, $category, $item_id, $event, $extra_tags=array(), $user_list=array(), $omit_user_id=null)
48
+    public function triggerEvent($mydirname, $mytrustdirname, $category, $item_id, $event, $extra_tags = array(), $user_list = array(), $omit_user_id = null)
49 49
     {
50
-        $module_hanlder =& xoops_gethandler('module') ;
51
-        $module =& $module_hanlder->getByDirname($mydirname) ;
50
+        $module_hanlder = & xoops_gethandler('module');
51
+        $module = & $module_hanlder->getByDirname($mydirname);
52 52
 
53
-        $notification_handler =& xoops_gethandler('notification') ;
54
-        $mail_template_dir = $this->getMailTemplateDir($mydirname, $mytrustdirname) ;
53
+        $notification_handler = & xoops_gethandler('notification');
54
+        $mail_template_dir = $this->getMailTemplateDir($mydirname, $mytrustdirname);
55 55
 
56 56
     // calling a delegate before
57 57
     if (class_exists('XCube_DelegateUtils')) {
58
-        $force_return = false ;
59
-        XCube_DelegateUtils::raiseEvent('D3NotificationHandler.Trigger', new XCube_Ref($category), new XCube_Ref($event), new XCube_Ref($item_id), new XCube_Ref($extra_tags), new XCube_Ref($module), new XCube_Ref($user_list), new XCube_Ref($omit_user_id), $module->getInfo('notification'), new XCube_Ref($force_return), new XCube_Ref($mail_template_dir), $mydirname, $mytrustdirname) ;
58
+        $force_return = false;
59
+        XCube_DelegateUtils::raiseEvent('D3NotificationHandler.Trigger', new XCube_Ref($category), new XCube_Ref($event), new XCube_Ref($item_id), new XCube_Ref($extra_tags), new XCube_Ref($module), new XCube_Ref($user_list), new XCube_Ref($omit_user_id), $module->getInfo('notification'), new XCube_Ref($force_return), new XCube_Ref($mail_template_dir), $mydirname, $mytrustdirname);
60 60
         if ($force_return) {
61
-            return ;
61
+            return;
62 62
         }
63 63
     }
64 64
 
65
-        $mid = $module->getVar('mid') ;
65
+        $mid = $module->getVar('mid');
66 66
 
67 67
     // Check if event is enabled
68
-    $config_handler =& xoops_gethandler('config');
69
-        $mod_config =& $config_handler->getConfigsByCat(0, $mid);
68
+    $config_handler = & xoops_gethandler('config');
69
+        $mod_config = & $config_handler->getConfigsByCat(0, $mid);
70 70
         if (empty($mod_config['notification_enabled'])) {
71 71
             return false;
72 72
         }
73
-        $category_info =& notificationCategoryInfo($category, $mid);
74
-        $event_info =& notificationEventInfo($category, $event, $mid);
73
+        $category_info = & notificationCategoryInfo($category, $mid);
74
+        $event_info = & notificationEventInfo($category, $event, $mid);
75 75
         if (!in_array(notificationGenerateConfig($category_info, $event_info, 'option_name'), $mod_config['notification_events']) && empty($event_info['invisible'])) {
76 76
             return false;
77 77
         }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE), 'OR');
95 95
         $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT), 'OR');
96 96
         $criteria->add($mode_criteria);
97
-        $notifications =& $notification_handler->getObjects($criteria);
97
+        $notifications = & $notification_handler->getObjects($criteria);
98 98
         if (empty($notifications)) {
99 99
             return;
100 100
         }
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
     $tags = array();
104 104
     // {X_ITEM_NAME} {X_ITEM_URL} {X_ITEM_TYPE} from lookup_func are disabled
105 105
     $tags['X_MODULE'] = $module->getVar('name', 'n');
106
-        $tags['X_MODULE_URL'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/';
106
+        $tags['X_MODULE_URL'] = XOOPS_URL.'/modules/'.$module->getVar('dirname').'/';
107 107
         $tags['X_NOTIFY_CATEGORY'] = $category;
108 108
         $tags['X_NOTIFY_EVENT'] = $event;
109 109
 
110
-        $template = $event_info['mail_template'] . '.tpl';
110
+        $template = $event_info['mail_template'].'.tpl';
111 111
         $subject = $event_info['mail_subject'];
112 112
 
113 113
         if ($user_list) {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 // user-specific tags
122 122
             //$tags['X_UNSUBSCRIBE_URL'] = 'TODO';
123 123
             // TODO: don't show unsubscribe link if it is 'one-time' ??
124
-            $tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL . '/notifications.php';
124
+            $tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL.'/notifications.php';
125 125
                 $tags = array_merge($tags, $extra_tags);
126 126
 
127 127
                 $notification->notifyUser($mail_template_dir, $template, $subject, $tags);
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/class/MyBlocksAdmin.class.php 1 patch
Spacing   +408 added lines, -408 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  discard block
 block discarded – undo
4 4
 class MyBlocksAdmin
5 5
 {
6 6
 
7
-    public $db ;
8
-    public $lang ;
9
-    public $cachetime_options = array() ;
10
-    public $ctype_options = array() ;
11
-    public $type_options = array() ;
12
-    public $target_mid = 0 ;
13
-    public $target_dirname = '' ;
14
-    public $target_mname = '' ;
15
-    public $block_configs = array() ;
16
-    public $preview_request = array() ;
7
+    public $db;
8
+    public $lang;
9
+    public $cachetime_options = array();
10
+    public $ctype_options = array();
11
+    public $type_options = array();
12
+    public $target_mid = 0;
13
+    public $target_dirname = '';
14
+    public $target_mname = '';
15
+    public $block_configs = array();
16
+    public $preview_request = array();
17 17
 
18 18
     public function MyBlocksAadmin()
19 19
     {
@@ -22,37 +22,37 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function construct()
24 24
     {
25
-        $this->db =& XoopsDatabaseFactory::getDatabaseConnection() ;
26
-        $this->lang = @$GLOBALS['xoopsConfig']['language'] ;
25
+        $this->db = & XoopsDatabaseFactory::getDatabaseConnection();
26
+        $this->lang = @$GLOBALS['xoopsConfig']['language'];
27 27
 
28 28
         $this->cachetime_options = array(
29
-        0 => _NOCACHE ,
30
-        30 => sprintf(_SECONDS, 30) ,
31
-        60 => _MINUTE ,
32
-        300 => sprintf(_MINUTES, 5) ,
33
-        1800 => sprintf(_MINUTES, 30) ,
34
-        3600 => _HOUR ,
35
-        18000 => sprintf(_HOURS, 5) ,
36
-        86400 => _DAY ,
37
-        259200 => sprintf(_DAYS, 3) ,
38
-        604800 => _WEEK ,
39
-        2592000 => _MONTH ,
29
+        0 => _NOCACHE,
30
+        30 => sprintf(_SECONDS, 30),
31
+        60 => _MINUTE,
32
+        300 => sprintf(_MINUTES, 5),
33
+        1800 => sprintf(_MINUTES, 30),
34
+        3600 => _HOUR,
35
+        18000 => sprintf(_HOURS, 5),
36
+        86400 => _DAY,
37
+        259200 => sprintf(_DAYS, 3),
38
+        604800 => _WEEK,
39
+        2592000 => _MONTH,
40 40
     );
41 41
 
42 42
         $this->ctype_options = array(
43
-        'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML ,
44
-        'T' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE ,
45
-        'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE ,
46
-        'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP ,
47
-    ) ;
43
+        'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML,
44
+        'T' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE,
45
+        'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE,
46
+        'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP,
47
+    );
48 48
 
49 49
         $this->type_options = array(
50
-        'C' => 'custom block' ,
51
-        'E' => 'cloned custom block' ,
52
-        'M' => 'module\'s block' ,
53
-        'D' => 'cloned module\'s block' ,
54
-        'S' => 'system block' ,
55
-    ) ;
50
+        'C' => 'custom block',
51
+        'E' => 'cloned custom block',
52
+        'M' => 'module\'s block',
53
+        'D' => 'cloned module\'s block',
54
+        'S' => 'system block',
55
+    );
56 56
     }
57 57
 
58 58
 //HACK by domifara for php5.3+
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 {
62 62
     static $instance;
63 63
     if (!isset($instance)) {
64
-        $instance = new MyBlocksAdmin() ;
65
-        $instance->construct() ;
64
+        $instance = new MyBlocksAdmin();
65
+        $instance->construct();
66 66
     }
67 67
     return $instance;
68 68
 }
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 public function checkPermission()
73 73
 {
74 74
     // only groups have 'module_admin' of 'altsys' can do that.
75
-    $module_handler =& xoops_gethandler('module') ;
76
-    $module =& $module_handler->getByDirname('altsys') ;
77
-    $moduleperm_handler =& xoops_gethandler('groupperm') ;
78
-    if (! is_object(@$GLOBALS['xoopsUser']) || ! $moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), $GLOBALS['xoopsUser']->getGroups())) {
79
-        die('only admin of altsys can access this area') ;
75
+    $module_handler = & xoops_gethandler('module');
76
+    $module = & $module_handler->getByDirname('altsys');
77
+    $moduleperm_handler = & xoops_gethandler('groupperm');
78
+    if (!is_object(@$GLOBALS['xoopsUser']) || !$moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), $GLOBALS['xoopsUser']->getGroups())) {
79
+        die('only admin of altsys can access this area');
80 80
     }
81 81
 }
82 82
 
@@ -86,53 +86,53 @@  discard block
 block discarded – undo
86 86
         // altsys "module" MODE
87 87
     if ($xoopsModule->getVar('dirname') == 'altsys') {
88 88
         // set target_module if specified by $_GET['dirname']
89
-        $module_handler =& xoops_gethandler('module');
90
-        if (! empty($_GET['dirname'])) {
91
-            $dirname = preg_replace('/[^0-9a-zA-Z_-]/', '', $_GET['dirname']) ;
92
-            $target_module =& $module_handler->getByDirname($dirname) ;
89
+        $module_handler = & xoops_gethandler('module');
90
+        if (!empty($_GET['dirname'])) {
91
+            $dirname = preg_replace('/[^0-9a-zA-Z_-]/', '', $_GET['dirname']);
92
+            $target_module = & $module_handler->getByDirname($dirname);
93 93
         }
94 94
 
95 95
         if (is_object(@$target_module)) {
96 96
             // module's blocks
97
-            $this->target_mid = $target_module->getVar('mid') ;
98
-            $this->target_mname = $target_module->getVar('name') . "&nbsp;" . sprintf("(%2.2f)", $target_module->getVar('version') / 100.0) ;
99
-            $this->target_dirname = $target_module->getVar('dirname') ;
100
-            $modinfo = $target_module->getInfo() ;
97
+            $this->target_mid = $target_module->getVar('mid');
98
+            $this->target_mname = $target_module->getVar('name')."&nbsp;".sprintf("(%2.2f)", $target_module->getVar('version') / 100.0);
99
+            $this->target_dirname = $target_module->getVar('dirname');
100
+            $modinfo = $target_module->getInfo();
101 101
             // breadcrumbs
102
-            $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ;
103
-            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN') ;
104
-            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname='.$this->target_dirname, $this->target_mname) ;
102
+            $breadcrumbsObj = & AltsysBreadcrumbs::getInstance();
103
+            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN');
104
+            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname='.$this->target_dirname, $this->target_mname);
105 105
         } else {
106 106
             // custom blocks
107
-            $this->target_mid = 0 ;
108
-            $this->target_mname = _MI_ALTSYS_MENU_CUSTOMBLOCKS ;
109
-            $this->target_dirname = '__CustomBlocks__' ;
107
+            $this->target_mid = 0;
108
+            $this->target_mname = _MI_ALTSYS_MENU_CUSTOMBLOCKS;
109
+            $this->target_dirname = '__CustomBlocks__';
110 110
             // breadcrumbs
111
-            $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ;
112
-            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN') ;
113
-            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname='.$this->target_dirname, '_MI_ALTSYS_MENU_CUSTOMBLOCKS') ;
111
+            $breadcrumbsObj = & AltsysBreadcrumbs::getInstance();
112
+            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN');
113
+            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname='.$this->target_dirname, '_MI_ALTSYS_MENU_CUSTOMBLOCKS');
114 114
         }
115 115
     } else {
116 116
         // myblocksadmin as a library
117
-        $this->target_mid = $xoopsModule->getVar('mid') ;
118
-        $this->target_mname = $xoopsModule->getVar('name') . "&nbsp;" . sprintf("(%2.2f)", $xoopsModule->getVar('version') / 100.0) ;
119
-        $this->target_dirname = $xoopsModule->getVar('dirname') ;
120
-        $mod_url = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname') ;
121
-        $modinfo = $xoopsModule->getInfo() ;
122
-        $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ;
123
-        $breadcrumbsObj->appendPath($mod_url.'/'.@$modinfo['adminindex'], $this->target_mname) ;
124
-        $breadcrumbsObj->appendPath($mod_url.'/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin', _MD_A_MYBLOCKSADMIN_BLOCKADMIN) ;
117
+        $this->target_mid = $xoopsModule->getVar('mid');
118
+        $this->target_mname = $xoopsModule->getVar('name')."&nbsp;".sprintf("(%2.2f)", $xoopsModule->getVar('version') / 100.0);
119
+        $this->target_dirname = $xoopsModule->getVar('dirname');
120
+        $mod_url = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname');
121
+        $modinfo = $xoopsModule->getInfo();
122
+        $breadcrumbsObj = & AltsysBreadcrumbs::getInstance();
123
+        $breadcrumbsObj->appendPath($mod_url.'/'.@$modinfo['adminindex'], $this->target_mname);
124
+        $breadcrumbsObj->appendPath($mod_url.'/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin', _MD_A_MYBLOCKSADMIN_BLOCKADMIN);
125 125
     }
126 126
 
127 127
     // read xoops_version.php of the target
128
-    $this->block_configs = $this->get_block_configs() ;
128
+    $this->block_configs = $this->get_block_configs();
129 129
     }
130 130
 
131 131
 
132 132
 // virtual
133 133
 public function canEdit($block)
134 134
 {
135
-    return true ;
135
+    return true;
136 136
 }
137 137
 
138 138
 
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 {
142 142
     // can delete if it is a cloned block
143 143
     if ($block->getVar("block_type") == 'D' || $block->getVar("block_type") == 'C') {
144
-        return true ;
144
+        return true;
145 145
     } else {
146
-        return false ;
146
+        return false;
147 147
     }
148 148
 }
149 149
 
@@ -156,23 +156,23 @@  discard block
 block discarded – undo
156 156
 {
157 157
     // can clone link if it is marked as cloneable block
158 158
     if ($block->getVar("block_type") == 'D' || $block->getVar("block_type") == 'C') {
159
-        return 2 ;
159
+        return 2;
160 160
     } else {
161 161
         // $modversion['blocks'][n]['can_clone']
162 162
         foreach ($this->block_configs as $bconf) {
163 163
             if ($block->getVar("show_func") == @$bconf['show_func'] && $block->getVar("func_file") == @$bconf['file'] && (empty($bconf['template']) || $block->getVar("template") == @$bconf['template'])) {
164
-                if (! empty($bconf['can_clone'])) {
165
-                    return 2 ;
164
+                if (!empty($bconf['can_clone'])) {
165
+                    return 2;
166 166
                 }
167 167
             }
168 168
         }
169 169
     }
170 170
 
171
-    if (! empty($GLOBALS['altsysModuleConfig']['enable_force_clone'])) {
172
-        return 1 ;
171
+    if (!empty($GLOBALS['altsysModuleConfig']['enable_force_clone'])) {
172
+        return 1;
173 173
     }
174 174
 
175
-    return 0 ;
175
+    return 0;
176 176
 }
177 177
 
178 178
 
@@ -180,17 +180,17 @@  discard block
 block discarded – undo
180 180
 // options
181 181
 public function renderCell4BlockOptions($block_data)
182 182
 {
183
-    $bid = intval($block_data['bid']) ;
183
+    $bid = intval($block_data['bid']);
184 184
 
185 185
 //HACK by domifara
186 186
     if (defined('XOOPS_CUBE_LEGACY')) {
187
-        $handler =& xoops_gethandler('block');
188
-        $block =& $handler->create(false) ;
189
-        $block->load($bid) ;
187
+        $handler = & xoops_gethandler('block');
188
+        $block = & $handler->create(false);
189
+        $block->load($bid);
190 190
     } else {
191
-        $block = new XoopsBlock($bid) ;
191
+        $block = new XoopsBlock($bid);
192 192
     }
193
-    return $block->getOptions() ;
193
+    return $block->getOptions();
194 194
 }
195 195
 
196 196
 
@@ -198,48 +198,48 @@  discard block
 block discarded – undo
198 198
 // link blocks - modules
199 199
 public function renderCell4BlockModuleLink($block_data)
200 200
 {
201
-    $bid = intval($block_data['bid']) ;
201
+    $bid = intval($block_data['bid']);
202 202
 
203 203
     // get selected targets
204 204
     if (is_array(@$block_data['bmodule'])) {
205 205
         // bmodule origined from request (preview etc.)
206
-        $selected_mids = $block_data['bmodule'] ;
206
+        $selected_mids = $block_data['bmodule'];
207 207
     } else {
208 208
         // origined from the table of `block_module_link`
209
-        $result = $this->db->query("SELECT module_id FROM ".$this->db->prefix('block_module_link')." WHERE block_id='$bid'") ;
209
+        $result = $this->db->query("SELECT module_id FROM ".$this->db->prefix('block_module_link')." WHERE block_id='$bid'");
210 210
         $selected_mids = array();
211 211
         while (list($selected_mid) = $this->db->fetchRow($result)) {
212
-            $selected_mids[] = intval($selected_mid) ;
212
+            $selected_mids[] = intval($selected_mid);
213 213
         }
214 214
         if (empty($selected_mids)) {
215
-            $selected_mids = array( 0 ) ;
215
+            $selected_mids = array(0);
216 216
         } // all pages
217 217
     }
218 218
 
219 219
     // get all targets
220
-    $module_handler =& xoops_gethandler('module');
220
+    $module_handler = & xoops_gethandler('module');
221 221
     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
222 222
     $criteria->add(new Criteria('isactive', 1));
223 223
     $module_list = $module_handler->getList($criteria);
224
-    $module_list= array( -1 => _MD_A_MYBLOCKSADMIN_TOPPAGE , 0 => _MD_A_MYBLOCKSADMIN_ALLPAGES ) + $module_list ;
224
+    $module_list = array( -1 => _MD_A_MYBLOCKSADMIN_TOPPAGE, 0 => _MD_A_MYBLOCKSADMIN_ALLPAGES ) + $module_list;
225 225
 
226 226
     // build options
227
-    $module_options = '' ;
227
+    $module_options = '';
228 228
     foreach ($module_list as $mid => $mname) {
229
-        $mname = htmlspecialchars($mname) ;
229
+        $mname = htmlspecialchars($mname);
230 230
         if (in_array($mid, $selected_mids)) {
231
-            $module_options .= "<option value='$mid' selected='selected'>$mname</option>\n" ;
231
+            $module_options .= "<option value='$mid' selected='selected'>$mname</option>\n";
232 232
         } else {
233
-            $module_options .= "<option value='$mid'>$mname</option>\n" ;
233
+            $module_options .= "<option value='$mid'>$mname</option>\n";
234 234
         }
235 235
     }
236 236
 
237 237
     $ret = "
238 238
 				<select name='bmodules[$bid][]' size='5' multiple='multiple'>
239 239
 					$module_options
240
-				</select>" ;
240
+				</select>";
241 241
 
242
-    return $ret ;
242
+    return $ret;
243 243
 }
244 244
 
245 245
 
@@ -247,46 +247,46 @@  discard block
 block discarded – undo
247 247
 // group_permission - 'block_read'
248 248
 public function renderCell4BlockReadGroupPerm($block_data)
249 249
 {
250
-    $bid = intval($block_data['bid']) ;
250
+    $bid = intval($block_data['bid']);
251 251
 
252 252
     // get selected targets
253 253
     if (is_array(@$block_data['bgroup'])) {
254 254
         // bgroup origined from request (preview etc.)
255
-        $selected_gids = $block_data['bgroup'] ;
255
+        $selected_gids = $block_data['bgroup'];
256 256
     } else {
257 257
         // origined from the table of `group_perm`
258
-        $result = $this->db->query("SELECT gperm_groupid FROM ".$this->db->prefix('group_permission')." WHERE gperm_itemid='$bid' AND gperm_name='block_read'") ;
258
+        $result = $this->db->query("SELECT gperm_groupid FROM ".$this->db->prefix('group_permission')." WHERE gperm_itemid='$bid' AND gperm_name='block_read'");
259 259
         $selected_gids = array();
260 260
         while (list($selected_gid) = $this->db->fetchRow($result)) {
261
-            $selected_gids[] = intval($selected_gid) ;
261
+            $selected_gids[] = intval($selected_gid);
262 262
         }
263 263
         if ($bid == 0 && empty($selected_gids)) {
264
-            $selected_gids = $GLOBALS['xoopsUser']->getGroups() ;
264
+            $selected_gids = $GLOBALS['xoopsUser']->getGroups();
265 265
         }
266 266
     }
267 267
 
268 268
     // get all targets
269
-    $group_handler =& xoops_gethandler('group');
270
-    $groups = $group_handler->getObjects() ;
269
+    $group_handler = & xoops_gethandler('group');
270
+    $groups = $group_handler->getObjects();
271 271
 
272 272
     // build options
273
-    $group_options = '' ;
273
+    $group_options = '';
274 274
     foreach ($groups as $group) {
275
-        $gid = $group->getVar('groupid') ;
276
-        $gname = $group->getVar('name', 's') ;
275
+        $gid = $group->getVar('groupid');
276
+        $gname = $group->getVar('name', 's');
277 277
         if (in_array($gid, $selected_gids)) {
278
-            $group_options .= "<option value='$gid' selected='selected'>$gname</option>\n" ;
278
+            $group_options .= "<option value='$gid' selected='selected'>$gname</option>\n";
279 279
         } else {
280
-            $group_options .= "<option value='$gid'>$gname</option>\n" ;
280
+            $group_options .= "<option value='$gid'>$gname</option>\n";
281 281
         }
282 282
     }
283 283
 
284 284
     $ret = "
285 285
 				<select name='bgroups[$bid][]' size='5' multiple='multiple'>
286 286
 					$group_options
287
-				</select>" ;
287
+				</select>";
288 288
 
289
-    return $ret ;
289
+    return $ret;
290 290
 }
291 291
 
292 292
 
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
 // visible and side
295 295
 public function renderCell4BlockPosition($block_data)
296 296
 {
297
-    $bid = intval($block_data['bid']) ;
298
-    $side = intval($block_data['side']) ;
299
-    $visible = intval($block_data['visible']) ;
297
+    $bid = intval($block_data['bid']);
298
+    $side = intval($block_data['side']);
299
+    $visible = intval($block_data['visible']);
300 300
 
301 301
     $sseln = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = "";
302 302
     $scoln = $scol0 = $scol1 = $scol2 = $scol3 = $scol4 = "unselected";
303
-    $stextbox = "unselected" ;
304
-    $value4extra_side = '' ;
303
+    $stextbox = "unselected";
304
+    $value4extra_side = '';
305 305
 
306 306
     if ($visible != 1) {
307 307
         $sseln = " checked='checked'";
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
         case XOOPS_SIDEBLOCK_LEFT :
312 312
             $ssel0 = " checked='checked'";
313 313
             $scol0 = "selected";
314
-            break ;
314
+            break;
315 315
         case XOOPS_SIDEBLOCK_RIGHT :
316 316
             $ssel1 = " checked='checked'";
317 317
             $scol1 = "selected";
318
-            break ;
318
+            break;
319 319
         case XOOPS_CENTERBLOCK_LEFT :
320 320
             $ssel2 = " checked='checked'";
321 321
             $scol2 = "selected";
322
-            break ;
322
+            break;
323 323
         case XOOPS_CENTERBLOCK_RIGHT :
324 324
             $ssel4 = " checked='checked'";
325 325
             $scol4 = "selected";
326
-            break ;
326
+            break;
327 327
         case XOOPS_CENTERBLOCK_CENTER :
328 328
             $ssel3 = " checked='checked'";
329 329
             $scol3 = "selected";
330
-            break ;
330
+            break;
331 331
         default :
332
-            $value4extra_side = $side ;
333
-            $stextbox = "selected" ;
334
-            break ;
332
+            $value4extra_side = $side;
333
+            $stextbox = "selected";
334
+            break;
335 335
     }
336 336
     }
337 337
 
@@ -369,58 +369,58 @@  discard block
 block discarded – undo
369 369
 // public
370 370
 public function list_blocks()
371 371
 {
372
-    global $xoopsGTicket ;
372
+    global $xoopsGTicket;
373 373
 
374 374
     // main query
375
-    $sql = "SELECT * FROM ".$this->db->prefix("newblocks")." WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight" ;
376
-    $result = $this->db->query($sql) ;
377
-    $block_arr = array() ;
375
+    $sql = "SELECT * FROM ".$this->db->prefix("newblocks")." WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight";
376
+    $result = $this->db->query($sql);
377
+    $block_arr = array();
378 378
 //HACK by domifara
379 379
     if (defined('XOOPS_CUBE_LEGACY')) {
380
-        $handler =& xoops_gethandler('block');//add
380
+        $handler = & xoops_gethandler('block'); //add
381 381
     }
382 382
     while ($myrow = $this->db->fetchArray($result)) {
383 383
 
384 384
 //HACK by domifara
385 385
         if (defined('XOOPS_CUBE_LEGACY')) {
386
-            $block_one =& $handler->create(false) ;
386
+            $block_one = & $handler->create(false);
387 387
             $block_one->assignVars($myrow);
388
-            $block_arr[] =& $block_one ;
388
+            $block_arr[] = & $block_one;
389 389
         } else {
390
-            $block_arr[] = new XoopsBlock($myrow) ;
390
+            $block_arr[] = new XoopsBlock($myrow);
391 391
         }
392 392
     }
393 393
     if (empty($block_arr)) {
394
-        return ;
394
+        return;
395 395
     }
396 396
 
397 397
     // blocks rendering loop
398
-    $blocks4assign = array() ;
398
+    $blocks4assign = array();
399 399
     foreach ($block_arr as $i => $block) {
400 400
         $block_data = array(
401
-            'bid' => intval($block->getVar('bid')) ,
402
-            'name' => $block->getVar('name', 'n') ,
403
-            'title' => $block->getVar('title', 'n') ,
404
-            'weight' => intval($block->getVar('weight')) ,
405
-            'bcachetime' => intval($block->getVar('bcachetime')) ,
406
-            'side' => intval($block->getVar('side')) ,
407
-            'visible' => intval($block->getVar('visible')) ,
408
-            'can_edit' => $this->canEdit($block) ,
409
-            'can_delete' => $this->canDelete($block) ,
410
-            'can_clone' => $this->canClone($block) ,
411
-        ) ;
401
+            'bid' => intval($block->getVar('bid')),
402
+            'name' => $block->getVar('name', 'n'),
403
+            'title' => $block->getVar('title', 'n'),
404
+            'weight' => intval($block->getVar('weight')),
405
+            'bcachetime' => intval($block->getVar('bcachetime')),
406
+            'side' => intval($block->getVar('side')),
407
+            'visible' => intval($block->getVar('visible')),
408
+            'can_edit' => $this->canEdit($block),
409
+            'can_delete' => $this->canDelete($block),
410
+            'can_clone' => $this->canClone($block),
411
+        );
412 412
         $blocks4assign[] = array(
413
-            'name_raw' => $block_data['name'] ,
414
-            'title_raw' => $block_data['title'] ,
415
-            'cell_position' => $this->renderCell4BlockPosition($block_data) ,
416
-            'cell_module_link' =>  $this->renderCell4BlockModuleLink($block_data) ,
417
-            'cell_group_perm' =>  $this->renderCell4BlockReadGroupPerm($block_data) ,
418
-        ) + $block_data ;
413
+            'name_raw' => $block_data['name'],
414
+            'title_raw' => $block_data['title'],
415
+            'cell_position' => $this->renderCell4BlockPosition($block_data),
416
+            'cell_module_link' =>  $this->renderCell4BlockModuleLink($block_data),
417
+            'cell_group_perm' =>  $this->renderCell4BlockReadGroupPerm($block_data),
418
+        ) + $block_data;
419 419
     }
420 420
 
421 421
     // display
422
-    require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php' ;
423
-    $tpl = new D3Tpl() ;
422
+    require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php';
423
+    $tpl = new D3Tpl();
424 424
     $tpl->assign(array(
425 425
         'target_mid' => $this->target_mid,
426 426
         'target_dirname' => $this->target_dirname,
@@ -429,22 +429,22 @@  discard block
 block discarded – undo
429 429
         'cachetime_options' => $this->cachetime_options,
430 430
         'blocks' => $blocks4assign,
431 431
         'gticket_hidden' => $xoopsGTicket->getTicketHtml(__LINE__, 1800, 'myblocksadmin'),
432
-    )) ;
433
-    $tpl->display('db:altsys_main_myblocksadmin_list.html') ;
432
+    ));
433
+    $tpl->display('db:altsys_main_myblocksadmin_list.html');
434 434
 }
435 435
 
436 436
 
437 437
     public function get_block_configs()
438 438
     {
439 439
         if ($this->target_mid <= 0) {
440
-            return array() ;
440
+            return array();
441 441
         }
442
-        include XOOPS_ROOT_PATH.'/modules/'.$this->target_dirname.'/xoops_version.php' ;
442
+        include XOOPS_ROOT_PATH.'/modules/'.$this->target_dirname.'/xoops_version.php';
443 443
 
444 444
         if (empty($modversion['blocks'])) {
445
-            return array() ;
445
+            return array();
446 446
         } else {
447
-            return $modversion['blocks'] ;
447
+            return $modversion['blocks'];
448 448
         }
449 449
     }
450 450
 
@@ -452,51 +452,51 @@  discard block
 block discarded – undo
452 452
     public function list_groups()
453 453
     {
454 454
         // query for getting blocks
455
-    $sql = "SELECT * FROM ".$this->db->prefix("newblocks")." WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight" ;
456
-        $result = $this->db->query($sql) ;
457
-        $block_arr = array() ;
455
+    $sql = "SELECT * FROM ".$this->db->prefix("newblocks")." WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight";
456
+        $result = $this->db->query($sql);
457
+        $block_arr = array();
458 458
 //HACK by domifara
459 459
     if (defined('XOOPS_CUBE_LEGACY')) {
460
-        $handler =& xoops_gethandler('block');//add
460
+        $handler = & xoops_gethandler('block'); //add
461 461
     }
462 462
         while ($myrow = $this->db->fetchArray($result)) {
463 463
             //HACK by domifara
464 464
         if (defined('XOOPS_CUBE_LEGACY')) {
465
-            $block_one =& $handler->create(false) ;
465
+            $block_one = & $handler->create(false);
466 466
             $block_one->assignVars($myrow);
467
-            $block_arr[] =& $block_one ;
467
+            $block_arr[] = & $block_one;
468 468
         } else {
469
-            $block_arr[] = new XoopsBlock($myrow) ;
469
+            $block_arr[] = new XoopsBlock($myrow);
470 470
         }
471 471
         }
472 472
 
473
-        $item_list = array() ;
473
+        $item_list = array();
474 474
         foreach (array_keys($block_arr) as $i) {
475
-            $item_list[ $block_arr[$i]->getVar("bid") ] = $block_arr[$i]->getVar("title") ;
475
+            $item_list[$block_arr[$i]->getVar("bid")] = $block_arr[$i]->getVar("title");
476 476
         }
477 477
 
478
-        $form = new MyXoopsGroupPermForm(_MD_A_MYBLOCKSADMIN_PERMFORM, 1, 'block_read', '') ;
478
+        $form = new MyXoopsGroupPermForm(_MD_A_MYBLOCKSADMIN_PERMFORM, 1, 'block_read', '');
479 479
     // skip system (TODO)
480 480
     if ($this->target_mid > 1) {
481
-        $form->addAppendix('module_admin', $this->target_mid, $this->target_mname . ' ' . _MD_A_MYBLOCKSADMIN_PERM_MADMIN) ;
482
-        $form->addAppendix('module_read', $this->target_mid, $this->target_mname .' ' . _MD_A_MYBLOCKSADMIN_PERM_MREAD) ;
481
+        $form->addAppendix('module_admin', $this->target_mid, $this->target_mname.' '._MD_A_MYBLOCKSADMIN_PERM_MADMIN);
482
+        $form->addAppendix('module_read', $this->target_mid, $this->target_mname.' '._MD_A_MYBLOCKSADMIN_PERM_MREAD);
483 483
     }
484 484
         foreach ($item_list as $item_id => $item_name) {
485
-            $form->addItem($item_id, $item_name) ;
485
+            $form->addItem($item_id, $item_name);
486 486
         }
487
-        echo $form->render() ;
487
+        echo $form->render();
488 488
     }
489 489
 
490 490
 
491
-    public function update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $options=array())
491
+    public function update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $options = array())
492 492
     {
493 493
         global $xoopsConfig;
494 494
 
495 495
 //HACK by domifara
496 496
     if (defined('XOOPS_CUBE_LEGACY')) {
497
-        $handler =& xoops_gethandler('block');
498
-        $block =& $handler->create(false) ;
499
-        $block->load($bid) ;
497
+        $handler = & xoops_gethandler('block');
498
+        $block = & $handler->create(false);
499
+        $block->load($bid);
500 500
     } else {
501 501
         $block = new XoopsBlock($bid);
502 502
     }
@@ -515,10 +515,10 @@  discard block
 block discarded – undo
515 515
         }
516 516
         $block->setVar('bcachetime', $bcachetime);
517 517
         if (is_array($options) && count($options) > 0) {
518
-            $block->setVar('options', implode('|', $options)) ;
518
+            $block->setVar('options', implode('|', $options));
519 519
         }
520 520
         if ($block->getVar('block_type') == 'C') {
521
-            $name = $this->get_blockname_from_ctype($block->getVar('c_type')) ;
521
+            $name = $this->get_blockname_from_ctype($block->getVar('c_type'));
522 522
             $block->setVar('name', $name);
523 523
         }
524 524
         $msg = _MD_A_MYBLOCKSADMIN_DBUPDATED;
@@ -542,22 +542,22 @@  discard block
 block discarded – undo
542 542
         } else {
543 543
             $msg = 'Failed update of block. ID:'.$bid;
544 544
         }
545
-        return $msg ;
545
+        return $msg;
546 546
     }
547 547
 
548 548
 
549 549
 // virtual
550 550
 public function updateBlockModuleLink($bid, $bmodules)
551 551
 {
552
-    $bid = intval($bid) ;
553
-    $table = $this->db->prefix("block_module_link") ;
552
+    $bid = intval($bid);
553
+    $table = $this->db->prefix("block_module_link");
554 554
 
555
-    $sql = "DELETE FROM `$table` WHERE `block_id`=$bid" ;
556
-    $this->db->query($sql) ;
555
+    $sql = "DELETE FROM `$table` WHERE `block_id`=$bid";
556
+    $this->db->query($sql);
557 557
     foreach ($bmodules as $mid) {
558
-        $mid = intval($mid) ;
559
-        $sql = "INSERT INTO `$table` (`block_id`,`module_id`) VALUES ($bid,$mid)" ;
560
-        $this->db->query($sql) ;
558
+        $mid = intval($mid);
559
+        $sql = "INSERT INTO `$table` (`block_id`,`module_id`) VALUES ($bid,$mid)";
560
+        $this->db->query($sql);
561 561
     }
562 562
 }
563 563
 
@@ -565,177 +565,177 @@  discard block
 block discarded – undo
565 565
 // virtual
566 566
 public function updateBlockReadGroupPerm($bid, $req_gids)
567 567
 {
568
-    $bid = intval($bid) ;
569
-    $table = $this->db->prefix("group_permission") ;
570
-    $req_gids = array_map('intval', $req_gids) ;
571
-    sort($req_gids) ;
568
+    $bid = intval($bid);
569
+    $table = $this->db->prefix("group_permission");
570
+    $req_gids = array_map('intval', $req_gids);
571
+    sort($req_gids);
572 572
 
573 573
     // compare group ids from request and the records.
574
-    $sql = "SELECT `gperm_groupid` FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid" ;
575
-    $result = $this->db->query($sql) ;
576
-    $db_gids = array() ;
574
+    $sql = "SELECT `gperm_groupid` FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid";
575
+    $result = $this->db->query($sql);
576
+    $db_gids = array();
577 577
     while (list($gid) = $this->db->fetchRow($result)) {
578
-        $db_gids[] = $gid ;
578
+        $db_gids[] = $gid;
579 579
     }
580
-    $db_gids = array_map('intval', $db_gids) ;
581
-    sort($db_gids) ;
580
+    $db_gids = array_map('intval', $db_gids);
581
+    sort($db_gids);
582 582
 
583 583
     // if they are identical, just return (prevent increase of gperm_id)
584 584
     if (serialize($req_gids) == serialize($db_gids)) {
585
-        return ;
585
+        return;
586 586
     }
587 587
 
588
-    $sql = "DELETE FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid" ;
589
-    $this->db->query($sql) ;
588
+    $sql = "DELETE FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid";
589
+    $this->db->query($sql);
590 590
     foreach ($req_gids as $gid) {
591
-        $gid = intval($gid) ;
592
-        $sql = "INSERT INTO `$table` (`gperm_groupid`,`gperm_itemid`,`gperm_modid`,`gperm_name`) VALUES ($gid,$bid,1,'block_read')" ;
593
-        $this->db->query($sql) ;
591
+        $gid = intval($gid);
592
+        $sql = "INSERT INTO `$table` (`gperm_groupid`,`gperm_itemid`,`gperm_modid`,`gperm_name`) VALUES ($gid,$bid,1,'block_read')";
593
+        $this->db->query($sql);
594 594
     }
595 595
 }
596 596
 
597 597
 
598 598
     public function do_order()
599 599
     {
600
-        $sides = is_array(@$_POST['sides']) ? $_POST['sides'] : array() ;
600
+        $sides = is_array(@$_POST['sides']) ? $_POST['sides'] : array();
601 601
         foreach (array_keys($sides) as $bid) {
602
-            $request = $this->fetchRequest4Block($bid) ;
602
+            $request = $this->fetchRequest4Block($bid);
603 603
 
604 604
         // update the block
605
-        $this->update_block($request['bid'], $request['side'], $request['weight'], $request['visible'], $request['title'], null, null, $request['bcachetime'], array()) ;
605
+        $this->update_block($request['bid'], $request['side'], $request['weight'], $request['visible'], $request['title'], null, null, $request['bcachetime'], array());
606 606
 
607 607
         // block_module_link update
608
-        $this->updateBlockModuleLink($bid, $request['bmodule']) ;
608
+        $this->updateBlockModuleLink($bid, $request['bmodule']);
609 609
 
610 610
         // group_permission update
611
-        $this->updateBlockReadGroupPerm($bid, $request['bgroup']) ;
611
+        $this->updateBlockReadGroupPerm($bid, $request['bgroup']);
612 612
         }
613
-        return _MD_A_MYBLOCKSADMIN_DBUPDATED ;
613
+        return _MD_A_MYBLOCKSADMIN_DBUPDATED;
614 614
     }
615 615
 
616 616
 
617 617
     public function fetchRequest4Block($bid)
618 618
     {
619
-        $bid = intval($bid) ;
620
-        (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts =& MyTextSanitizer::getInstance() ;
619
+        $bid = intval($bid);
620
+        (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = & MyTextSanitizer::getInstance();
621 621
 
622 622
         if (@$_POST['extra_sides'][$bid] > 0) {
623
-            $_POST['sides'][$bid] = intval($_POST['extra_sides'][$bid]) ;
623
+            $_POST['sides'][$bid] = intval($_POST['extra_sides'][$bid]);
624 624
         }
625 625
 
626 626
         if (@$_POST['sides'][$bid] < 0) {
627
-            $visible = 0 ;
628
-            $_POST['sides'][$bid] = -1 ;
627
+            $visible = 0;
628
+            $_POST['sides'][$bid] = -1;
629 629
         } else {
630
-            $visible = 1 ;
630
+            $visible = 1;
631 631
         }
632 632
 
633 633
         return array(
634
-        'bid' => $bid ,
635
-        'side' => intval(@$_POST['sides'][$bid]) ,
636
-        'weight' => intval(@$_POST['weights'][$bid]) ,
637
-        'visible' => $visible ,
638
-        'title' => $myts->stripSlashesGPC(@$_POST['titles'][$bid]) ,
639
-        'content' => $myts->stripSlashesGPC(@$_POST['contents'][$bid]) ,
640
-        'ctype' => preg_replace('/[^A-Z]/', '', @$_POST['ctypes'][$bid]) ,
641
-        'bcachetime' => intval(@$_POST['bcachetimes'][$bid]) ,
642
-        'bmodule' => is_array(@$_POST['bmodules'][$bid]) ? $_POST['bmodules'][$bid] : array( 0 ) ,
643
-        'bgroup' => is_array(@$_POST['bgroups'][$bid]) ? $_POST['bgroups'][$bid] : array() ,
644
-        'options' => is_array(@$_POST['options'][$bid]) ? $_POST['options'][$bid] : array() ,
645
-    ) ;
634
+        'bid' => $bid,
635
+        'side' => intval(@$_POST['sides'][$bid]),
636
+        'weight' => intval(@$_POST['weights'][$bid]),
637
+        'visible' => $visible,
638
+        'title' => $myts->stripSlashesGPC(@$_POST['titles'][$bid]),
639
+        'content' => $myts->stripSlashesGPC(@$_POST['contents'][$bid]),
640
+        'ctype' => preg_replace('/[^A-Z]/', '', @$_POST['ctypes'][$bid]),
641
+        'bcachetime' => intval(@$_POST['bcachetimes'][$bid]),
642
+        'bmodule' => is_array(@$_POST['bmodules'][$bid]) ? $_POST['bmodules'][$bid] : array(0),
643
+        'bgroup' => is_array(@$_POST['bgroups'][$bid]) ? $_POST['bgroups'][$bid] : array(),
644
+        'options' => is_array(@$_POST['options'][$bid]) ? $_POST['options'][$bid] : array(),
645
+    );
646 646
     }
647 647
 
648 648
 
649 649
     public function do_delete($bid)
650 650
     {
651
-        $bid = intval($bid) ;
651
+        $bid = intval($bid);
652 652
 
653 653
 //HACK by domifara
654 654
     if (defined('XOOPS_CUBE_LEGACY')) {
655
-        $handler =& xoops_gethandler('block');
656
-        $block =& $handler->create(false) ;
657
-        $block->load($bid) ;
655
+        $handler = & xoops_gethandler('block');
656
+        $block = & $handler->create(false);
657
+        $block->load($bid);
658 658
     } else {
659
-        $block = new XoopsBlock($bid) ;
659
+        $block = new XoopsBlock($bid);
660 660
     }
661 661
 
662
-        if (! is_object($block)) {
663
-            die('Invalid bid') ;
662
+        if (!is_object($block)) {
663
+            die('Invalid bid');
664 664
         }
665
-        if (! $this->canDelete($block)) {
666
-            die('Cannot delete this block') ;
665
+        if (!$this->canDelete($block)) {
666
+            die('Cannot delete this block');
667 667
         }
668 668
         $this->do_deleteBlockReadGroupPerm($bid); //HACK add by domifara
669
-    $block->delete() ;
670
-        return _MD_A_MYBLOCKSADMIN_DBUPDATED ;
669
+    $block->delete();
670
+        return _MD_A_MYBLOCKSADMIN_DBUPDATED;
671 671
     }
672 672
 
673 673
 //HACK add by domifara
674 674
 public function do_deleteBlockReadGroupPerm($bid)
675 675
 {
676
-    $bid = intval($bid) ;
677
-    $table = $this->db->prefix("group_permission") ;
678
-    $sql = "DELETE FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid" ;
679
-    $this->db->query($sql) ;
676
+    $bid = intval($bid);
677
+    $table = $this->db->prefix("group_permission");
678
+    $sql = "DELETE FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid";
679
+    $this->db->query($sql);
680 680
 }
681 681
 
682 682
     public function form_delete($bid)
683 683
     {
684
-        $bid = intval($bid) ;
684
+        $bid = intval($bid);
685 685
 
686 686
 //HACK by domifara
687 687
 //HACK by domifara
688 688
     if (defined('XOOPS_CUBE_LEGACY')) {
689
-        $handler =& xoops_gethandler('block');
690
-        $block =& $handler->create(false) ;
691
-        $block->load($bid) ;
689
+        $handler = & xoops_gethandler('block');
690
+        $block = & $handler->create(false);
691
+        $block->load($bid);
692 692
     } else {
693
-        $block = new XoopsBlock($bid) ;
693
+        $block = new XoopsBlock($bid);
694 694
     }
695 695
 
696
-        if (! is_object($block)) {
697
-            die('Invalid bid') ;
696
+        if (!is_object($block)) {
697
+            die('Invalid bid');
698 698
         }
699
-        if (! $this->canDelete($block)) {
700
-            die('Cannot delete this block') ;
699
+        if (!$this->canDelete($block)) {
700
+            die('Cannot delete this block');
701 701
         }
702 702
 
703 703
     // breadcrumbs
704
-    $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ;
705
-        $breadcrumbsObj->appendPath('', _DELETE) ;
704
+    $breadcrumbsObj = & AltsysBreadcrumbs::getInstance();
705
+        $breadcrumbsObj->appendPath('', _DELETE);
706 706
 
707
-        xoops_confirm(array( 'op' => 'delete_ok' ) + $GLOBALS['xoopsGTicket']->getTicketArray(__LINE__, 1800, 'myblocksadmin'), "?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname=$this->target_dirname&amp;bid=$bid", sprintf(_MD_A_MYBLOCKSADMIN_FMT_REMOVEBLOCK, $block->getVar('title'))) ;
707
+        xoops_confirm(array('op' => 'delete_ok') + $GLOBALS['xoopsGTicket']->getTicketArray(__LINE__, 1800, 'myblocksadmin'), "?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname=$this->target_dirname&amp;bid=$bid", sprintf(_MD_A_MYBLOCKSADMIN_FMT_REMOVEBLOCK, $block->getVar('title')));
708 708
     }
709 709
 
710 710
 
711 711
     public function do_clone($bid)
712 712
     {
713
-        $bid = intval($bid) ;
713
+        $bid = intval($bid);
714 714
 
715
-        $request = $this->fetchRequest4Block($bid) ;
715
+        $request = $this->fetchRequest4Block($bid);
716 716
 
717 717
 //HACK by domifara
718 718
     if (defined('XOOPS_CUBE_LEGACY')) {
719
-        $handler =& xoops_gethandler('block');
720
-        $block =& $handler->create(false) ;
721
-        $block->load($bid) ;
719
+        $handler = & xoops_gethandler('block');
720
+        $block = & $handler->create(false);
721
+        $block->load($bid);
722 722
     } else {
723
-        $block = new XoopsBlock($bid) ;
723
+        $block = new XoopsBlock($bid);
724 724
     }
725 725
 
726
-        if (! $block->getVar('bid')) {
727
-            die('Invalid bid') ;
726
+        if (!$block->getVar('bid')) {
727
+            die('Invalid bid');
728 728
         }
729
-        if (! $this->canClone($block)) {
730
-            die('Invalid block_type') ;
729
+        if (!$this->canClone($block)) {
730
+            die('Invalid block_type');
731 731
         }
732 732
 
733 733
         if (empty($_POST['options'])) {
734
-            $options = array() ;
734
+            $options = array();
735 735
         } elseif (is_array($_POST['options'])) {
736
-            $options = $_POST['options'] ;
736
+            $options = $_POST['options'];
737 737
         } else {
738
-            $options = explode('|', $_POST['options']) ;
738
+            $options = explode('|', $_POST['options']);
739 739
         }
740 740
 
741 741
     // for backward compatibility
@@ -743,150 +743,150 @@  discard block
 block discarded – undo
743 743
 
744 744
 //HACK by domifara
745 745
     if (defined('XOOPS_CUBE_LEGACY')) {
746
-        $cblock =& $handler->create(false) ;
746
+        $cblock = & $handler->create(false);
747 747
     } else {
748
-        $cblock = new XoopsBlock() ;
748
+        $cblock = new XoopsBlock();
749 749
     }
750 750
 
751 751
         foreach ($block->vars as $k => $v) {
752
-            $cblock->assignVar($k, $v['value']) ;
752
+            $cblock->assignVar($k, $v['value']);
753 753
         }
754 754
         $cblock->setNew();
755 755
         $cblock->setVar('bid', 0);
756 756
         $cblock->setVar('block_type', $block->getVar('block_type') == 'C' ? 'C' : 'D');
757
-        $cblock->setVar('func_num', $this->find_func_num_vacancy($block->getVar('mid'))) ;
757
+        $cblock->setVar('func_num', $this->find_func_num_vacancy($block->getVar('mid')));
758 758
     // store the block into DB as a new one
759
-    $newbid = $cblock->store() ;
760
-        if (! $newbid) {
761
-            return $cblock->getHtmlErrors() ;
759
+    $newbid = $cblock->store();
760
+        if (!$newbid) {
761
+            return $cblock->getHtmlErrors();
762 762
         }
763 763
 
764 764
     // update the block by the request
765
-    $this->update_block($newbid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array()) ;
765
+    $this->update_block($newbid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array());
766 766
 
767 767
     // block_module_link update
768
-    $this->updateBlockModuleLink($newbid, $request['bmodule']) ;
768
+    $this->updateBlockModuleLink($newbid, $request['bmodule']);
769 769
 
770 770
     // group_permission update
771
-    $this->updateBlockReadGroupPerm($newbid, $request['bgroup']) ;
771
+    $this->updateBlockReadGroupPerm($newbid, $request['bgroup']);
772 772
 
773
-        return _MD_A_MYBLOCKSADMIN_DBUPDATED ;
773
+        return _MD_A_MYBLOCKSADMIN_DBUPDATED;
774 774
     }
775 775
 
776 776
 
777 777
     public function find_func_num_vacancy($mid)
778 778
     {
779
-        $func_num = 256 ;
779
+        $func_num = 256;
780 780
         do {
781
-            $func_num -- ;
782
-            list($count) = $this->db->fetchRow($this->db->query("SELECT COUNT(*) FROM ".$this->db->prefix("newblocks")." WHERE mid=".intval($mid)." AND func_num=".$func_num)) ;
783
-        } while ($count > 0) ;
781
+            $func_num--;
782
+            list($count) = $this->db->fetchRow($this->db->query("SELECT COUNT(*) FROM ".$this->db->prefix("newblocks")." WHERE mid=".intval($mid)." AND func_num=".$func_num));
783
+        } while ($count > 0);
784 784
 
785
-        return $func_num > 128 ? $func_num : 255 ;
785
+        return $func_num > 128 ? $func_num : 255;
786 786
     }
787 787
 
788 788
 
789 789
     public function do_edit($bid)
790 790
     {
791
-        $bid = intval($bid) ;
791
+        $bid = intval($bid);
792 792
 
793 793
         if ($bid <= 0) {
794 794
             // new custom block
795 795
 
796 796
 //HACK by domifara
797 797
     if (defined('XOOPS_CUBE_LEGACY')) {
798
-        $handler =& xoops_gethandler('block');
799
-        $new_block =& $handler->create(false) ;
798
+        $handler = & xoops_gethandler('block');
799
+        $new_block = & $handler->create(false);
800 800
     } else {
801
-        $new_block = new XoopsBlock() ;
801
+        $new_block = new XoopsBlock();
802 802
     }
803 803
 
804
-            $new_block->setNew() ;
805
-            $new_block->setVar('name', $this->get_blockname_from_ctype('C')) ;
806
-            $new_block->setVar('block_type', 'C') ;
807
-            $new_block->setVar('func_num', 0) ;
808
-            $bid = $new_block->store() ;
809
-            $request = $this->fetchRequest4Block(0) ;
804
+            $new_block->setNew();
805
+            $new_block->setVar('name', $this->get_blockname_from_ctype('C'));
806
+            $new_block->setVar('block_type', 'C');
807
+            $new_block->setVar('func_num', 0);
808
+            $bid = $new_block->store();
809
+            $request = $this->fetchRequest4Block(0);
810 810
         // permission copy
811 811
         foreach ($GLOBALS['xoopsUser']->getGroups() as $gid) {
812 812
             $sql = "INSERT INTO ".$this->db->prefix('group_permission')." (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ($gid, $bid, 1, 'block_read')";
813 813
             $this->db->query($sql);
814 814
         }
815 815
         } else {
816
-            $request = $this->fetchRequest4Block($bid) ;
816
+            $request = $this->fetchRequest4Block($bid);
817 817
         }
818 818
 
819 819
     // update the block by the request
820
-    $msg = $this->update_block($bid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array()) ;
820
+    $msg = $this->update_block($bid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array());
821 821
 
822 822
     // block_module_link update
823
-    $this->updateBlockModuleLink($bid, $request['bmodule']) ;
823
+    $this->updateBlockModuleLink($bid, $request['bmodule']);
824 824
 
825 825
     // group_permission update
826
-    $this->updateBlockReadGroupPerm($bid, $request['bgroup']) ;
826
+    $this->updateBlockReadGroupPerm($bid, $request['bgroup']);
827 827
 
828
-        return $msg ;
828
+        return $msg;
829 829
     }
830 830
 
831 831
 
832 832
     public function form_edit($bid, $mode = 'edit')
833 833
     {
834
-        $bid = intval($bid) ;
834
+        $bid = intval($bid);
835 835
 
836 836
 //HACK by domifara
837 837
     if (defined('XOOPS_CUBE_LEGACY')) {
838
-        $handler =& xoops_gethandler('block');
839
-        $block =& $handler->create(false) ;
840
-        $block->load($bid) ;
838
+        $handler = & xoops_gethandler('block');
839
+        $block = & $handler->create(false);
840
+        $block->load($bid);
841 841
     } else {
842
-        $block = new XoopsBlock($bid) ;
842
+        $block = new XoopsBlock($bid);
843 843
     }
844 844
 
845
-        if (! $block->getVar('bid')) {
845
+        if (!$block->getVar('bid')) {
846 846
             // new defaults
847
-        $bid = 0 ;
848
-            $mode = 'new' ;
849
-            $block->setVar('mid', 0) ;
850
-            $block->setVar('block_type', 'C') ;
847
+        $bid = 0;
848
+            $mode = 'new';
849
+            $block->setVar('mid', 0);
850
+            $block->setVar('block_type', 'C');
851 851
         }
852 852
 
853 853
         switch ($mode) {
854 854
         case 'clone' :
855
-            $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM ;
856
-            $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE ;
857
-            $next_op = 'clone_ok' ;
855
+            $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM;
856
+            $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE;
857
+            $next_op = 'clone_ok';
858 858
             // breadcrumbs
859
-            $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ;
860
-            $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM) ;
861
-            break ;
859
+            $breadcrumbsObj = & AltsysBreadcrumbs::getInstance();
860
+            $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM);
861
+            break;
862 862
         case 'new' :
863
-            $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM ;
864
-            $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW ;
865
-            $next_op = 'new_ok' ;
863
+            $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM;
864
+            $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW;
865
+            $next_op = 'new_ok';
866 866
             // breadcrumbs
867
-            $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ;
868
-            $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM) ;
869
-            break ;
867
+            $breadcrumbsObj = & AltsysBreadcrumbs::getInstance();
868
+            $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM);
869
+            break;
870 870
         case 'edit' :
871 871
         default :
872
-            $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM ;
873
-            $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT ;
874
-            $next_op = 'edit_ok' ;
872
+            $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM;
873
+            $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT;
874
+            $next_op = 'edit_ok';
875 875
             // breadcrumbs
876
-            $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ;
877
-            $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM) ;
878
-            break ;
876
+            $breadcrumbsObj = & AltsysBreadcrumbs::getInstance();
877
+            $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM);
878
+            break;
879 879
     }
880 880
 
881
-        $is_custom = in_array($block->getVar('block_type'), array( 'C', 'E' )) ? true : false ;
882
-        $block_template = $block->getVar('template', 'n') ;
883
-        $block_template_tplset = '' ;
881
+        $is_custom = in_array($block->getVar('block_type'), array('C', 'E')) ? true : false;
882
+        $block_template = $block->getVar('template', 'n');
883
+        $block_template_tplset = '';
884 884
 
885
-        if (! $is_custom && $block_template) {
885
+        if (!$is_custom && $block_template) {
886 886
             // find template of the block
887
-        $tplfile_handler =& xoops_gethandler('tplfile');
888
-            $found_templates = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', null, null, $block_template) ;
889
-            $block_template_tplset = count($found_templates) > 0 ? $GLOBALS['xoopsConfig']['template_set'] : 'default' ;
887
+        $tplfile_handler = & xoops_gethandler('tplfile');
888
+            $found_templates = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', null, null, $block_template);
889
+            $block_template_tplset = count($found_templates) > 0 ? $GLOBALS['xoopsConfig']['template_set'] : 'default';
890 890
         }
891 891
 //HACK by domifara
892 892
 /*
@@ -895,43 +895,43 @@  discard block
 block discarded – undo
895 895
     }
896 896
 */
897 897
     $block_data = $this->preview_request + array(
898
-        'bid' => $bid ,
899
-        'name' => $block->getVar('name', 'n') ,
900
-        'title' => $block->getVar('title', 'n') ,
901
-        'weight' => intval($block->getVar('weight')) ,
902
-        'bcachetime' => intval($block->getVar('bcachetime')) ,
903
-        'side' => intval($block->getVar('side')) ,
904
-        'visible' => intval($block->getVar('visible')) ,
905
-        'template' => $block_template ,
906
-        'template_tplset' => $block_template_tplset ,
907
-        'options' => $block->getVar('options') ,
908
-        'content' => $block->getVar('content', 'n') ,
909
-        'is_custom' => $is_custom ,
910
-        'type' => $block->getVar('block_type') ,
911
-        'ctype' => $block->getVar('c_type') ,
912
-    ) ;
898
+        'bid' => $bid,
899
+        'name' => $block->getVar('name', 'n'),
900
+        'title' => $block->getVar('title', 'n'),
901
+        'weight' => intval($block->getVar('weight')),
902
+        'bcachetime' => intval($block->getVar('bcachetime')),
903
+        'side' => intval($block->getVar('side')),
904
+        'visible' => intval($block->getVar('visible')),
905
+        'template' => $block_template,
906
+        'template_tplset' => $block_template_tplset,
907
+        'options' => $block->getVar('options'),
908
+        'content' => $block->getVar('content', 'n'),
909
+        'is_custom' => $is_custom,
910
+        'type' => $block->getVar('block_type'),
911
+        'ctype' => $block->getVar('c_type'),
912
+    );
913 913
 
914 914
         $block4assign = array(
915
-        'name_raw' => $block_data['name'] ,
916
-        'title_raw' => $block_data['title'] ,
917
-        'content_raw' => $block_data['content'] ,
918
-        'cell_position' => $this->renderCell4BlockPosition($block_data) ,
919
-        'cell_module_link' => $this->renderCell4BlockModuleLink($block_data) ,
920
-        'cell_group_perm' =>  $this->renderCell4BlockReadGroupPerm($block_data) ,
921
-        'cell_options' => $this->renderCell4BlockOptions($block_data) ,
922
-        'content_preview' => $this->previewContent($block_data) ,
923
-    ) + $block_data ;
915
+        'name_raw' => $block_data['name'],
916
+        'title_raw' => $block_data['title'],
917
+        'content_raw' => $block_data['content'],
918
+        'cell_position' => $this->renderCell4BlockPosition($block_data),
919
+        'cell_module_link' => $this->renderCell4BlockModuleLink($block_data),
920
+        'cell_group_perm' =>  $this->renderCell4BlockReadGroupPerm($block_data),
921
+        'cell_options' => $this->renderCell4BlockOptions($block_data),
922
+        'content_preview' => $this->previewContent($block_data),
923
+    ) + $block_data;
924 924
 
925 925
     // display
926
-    require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php' ;
927
-        $tpl = new D3Tpl() ;
926
+    require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php';
927
+        $tpl = new D3Tpl();
928 928
 
929 929
     //HACK by domifara
930 930
     if (defined('XOOPS_CUBE_LEGACY')) {
931
-        $tpl->assign('xoops_cube_legacy', true) ;
931
+        $tpl->assign('xoops_cube_legacy', true);
932 932
         include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
933 933
     } else {
934
-        $tpl->assign('xoops_cube_legacy', false) ;
934
+        $tpl->assign('xoops_cube_legacy', false);
935 935
     }
936 936
 
937 937
         $tpl->assign(array(
@@ -946,14 +946,14 @@  discard block
 block discarded – undo
946 946
         'submit_button' => $button_value,
947 947
         'common_fck_installed' => $this->checkFck(),
948 948
         'gticket_hidden' => $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__, 1800, 'myblocksadmin'),
949
-    )) ;
949
+    ));
950 950
 
951 951
         if (defined('XOOPS_CUBE_LEGACY')) {
952
-            $tpl->display('db:altsys_main_myblocksadmin_edit_4legacy.html') ;
952
+            $tpl->display('db:altsys_main_myblocksadmin_edit_4legacy.html');
953 953
         } else {
954
-            $tpl->display('db:altsys_main_myblocksadmin_edit.html') ;
954
+            $tpl->display('db:altsys_main_myblocksadmin_edit.html');
955 955
         }
956
-        return ;
956
+        return;
957 957
     }
958 958
 
959 959
     public function checkFck()
@@ -963,18 +963,18 @@  discard block
 block discarded – undo
963 963
 
964 964
     public function previewContent($block_data)
965 965
     {
966
-        $bid = intval($block_data['bid']) ;
966
+        $bid = intval($block_data['bid']);
967 967
 
968
-        if (! $block_data['is_custom']) {
969
-            return '' ;
968
+        if (!$block_data['is_custom']) {
969
+            return '';
970 970
         }
971 971
         if (empty($this->preview_request)) {
972
-            return '' ;
972
+            return '';
973 973
         }
974 974
 
975 975
 //HACK by domifara
976 976
 //TODO : need no hook block at this
977
-    $block = new XoopsBlock($bid) ;
977
+    $block = new XoopsBlock($bid);
978 978
 /*
979 979
     $handler =& xoops_gethandler('block');
980 980
     $block =& $handler->create(false) ;
@@ -982,92 +982,92 @@  discard block
 block discarded – undo
982 982
 */
983 983
 
984 984
     if ($block->getVar('mid')) {
985
-        return '' ;
985
+        return '';
986 986
     }
987 987
 
988
-        $block->setVar('title', $block_data['title']) ;
989
-        $block->setVar('content', $block_data['content']) ;
988
+        $block->setVar('title', $block_data['title']);
989
+        $block->setVar('content', $block_data['content']);
990 990
 
991
-        restore_error_handler() ;
992
-        $original_level = error_reporting(E_ALL) ;
993
-        $ret = $block->getContent('S', $block_data['ctype']) ;
994
-        error_reporting($original_level) ;
991
+        restore_error_handler();
992
+        $original_level = error_reporting(E_ALL);
993
+        $ret = $block->getContent('S', $block_data['ctype']);
994
+        error_reporting($original_level);
995 995
 
996
-        return $ret ;
996
+        return $ret;
997 997
     }
998 998
 
999 999
 
1000 1000
     public function get_blockname_from_ctype($bctype)
1001 1001
     {
1002 1002
         $ctypes = array(
1003
-        'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML ,
1004
-        'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE ,
1005
-        'N' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE ,
1006
-        'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP ,
1007
-    ) ;
1003
+        'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML,
1004
+        'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE,
1005
+        'N' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE,
1006
+        'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP,
1007
+    );
1008 1008
 
1009
-        return isset($ctypes[$bctype]) ? $ctypes[$bctype] : _MD_A_MYBLOCKSADMIN_CTYPE_SMILE ;
1009
+        return isset($ctypes[$bctype]) ? $ctypes[$bctype] : _MD_A_MYBLOCKSADMIN_CTYPE_SMILE;
1010 1010
     }
1011 1011
 
1012 1012
 
1013 1013
     public function processPost()
1014 1014
     {
1015 1015
         // Ticket Check
1016
-    if (! $GLOBALS['xoopsGTicket']->check(true, 'myblocksadmin')) {
1016
+    if (!$GLOBALS['xoopsGTicket']->check(true, 'myblocksadmin')) {
1017 1017
         redirect_header(XOOPS_URL.'/', 3, $GLOBALS['xoopsGTicket']->getErrors());
1018 1018
     }
1019 1019
 
1020
-        $msg = '' ;
1021
-        $bid = intval(@$_GET['bid']) ;
1022
-        if (! empty($_POST['preview'])) {
1020
+        $msg = '';
1021
+        $bid = intval(@$_GET['bid']);
1022
+        if (!empty($_POST['preview'])) {
1023 1023
             // preview
1024
-        $this->preview_request = $this->fetchRequest4Block($bid) ;
1025
-            $_GET['op'] = str_replace('_ok', '', @$_POST['op']) ;
1026
-            return ; // continue ;
1024
+        $this->preview_request = $this->fetchRequest4Block($bid);
1025
+            $_GET['op'] = str_replace('_ok', '', @$_POST['op']);
1026
+            return; // continue ;
1027 1027
         } elseif (@$_POST['op'] == 'order') {
1028 1028
             // order ok
1029
-        $msg = $this->do_order() ;
1029
+        $msg = $this->do_order();
1030 1030
         } elseif (@$_POST['op'] == 'delete_ok') {
1031 1031
             // delete ok
1032
-        $msg = $this->do_delete($bid) ;
1032
+        $msg = $this->do_delete($bid);
1033 1033
         } elseif (@$_POST['op'] == 'clone_ok') {
1034 1034
             // clone ok
1035
-        $msg = $this->do_clone($bid) ;
1035
+        $msg = $this->do_clone($bid);
1036 1036
         } elseif (@$_POST['op'] == 'edit_ok' || @$_POST['op'] == 'new_ok') {
1037 1037
             // edit ok
1038
-        $msg = $this->do_edit($bid) ;
1039
-        } elseif (! empty($_POST['submit'])) {
1038
+        $msg = $this->do_edit($bid);
1039
+        } elseif (!empty($_POST['submit'])) {
1040 1040
             // update module_admin,module_read,block_read
1041
-        include dirname(dirname(__FILE__)).'/include/mygroupperm.php' ;
1042
-            $msg = _MD_A_MYBLOCKSADMIN_PERMUPDATED ;
1041
+        include dirname(dirname(__FILE__)).'/include/mygroupperm.php';
1042
+            $msg = _MD_A_MYBLOCKSADMIN_PERMUPDATED;
1043 1043
         }
1044 1044
 
1045
-        redirect_header('?mode=admin&lib=altsys&page=myblocksadmin&dirname='.$this->target_dirname, 1, $msg) ;
1046
-        exit ;
1045
+        redirect_header('?mode=admin&lib=altsys&page=myblocksadmin&dirname='.$this->target_dirname, 1, $msg);
1046
+        exit;
1047 1047
     }
1048 1048
 
1049 1049
 
1050 1050
     public function processGet()
1051 1051
     {
1052
-        $bid = intval(@$_GET['bid']) ;
1052
+        $bid = intval(@$_GET['bid']);
1053 1053
         switch (@$_GET['op']) {
1054 1054
         case 'clone' :
1055
-            $this->form_edit($bid, 'clone') ;
1056
-            break ;
1055
+            $this->form_edit($bid, 'clone');
1056
+            break;
1057 1057
         case 'new' :
1058 1058
         case 'edit' :
1059
-            $this->form_edit($bid, 'edit') ;
1060
-            break ;
1059
+            $this->form_edit($bid, 'edit');
1060
+            break;
1061 1061
         case 'delete' :
1062
-            $this->form_delete($bid) ;
1063
-            break ;
1062
+            $this->form_delete($bid);
1063
+            break;
1064 1064
         case 'list' :
1065 1065
         default :
1066 1066
             // the first form (blocks)
1067
-            $this->list_blocks() ;
1067
+            $this->list_blocks();
1068 1068
             // the second form (groups)
1069
-            $this->list_groups() ;
1070
-            break ;
1069
+            $this->list_groups();
1070
+            break;
1071 1071
     }
1072 1072
     }
1073 1073
 }
Please login to merge, or discard this patch.