25 public $mStatus = LEGACY_INSTALLINFO_STATUS_LOADED;
31 public $mOptions =
'';
33 public $mFuncFile =
'';
34 public $mShowFunc =
'';
35 public $mEditFunc =
'';
36 public $mTemplate =
'';
38 public function __construct($funcNum, $name, $funcFile, $showFunc, $editFunc, $template, $options =
null)
40 $this->mFuncNum = (int)$funcNum;
42 $this->mFuncFile = $funcFile;
43 $this->mShowFunc = $showFunc;
44 $this->mEditFunc = $editFunc;
45 $this->mTemplate = $template;
46 $this->mOptions = $options;
55 if ($this->mFuncNum != $block->mFuncNum) {
59 if ($this->mName != $block->mName) {
63 if ($this->mFuncFile != $block->mFuncFile) {
67 if ($this->mShowFunc != $block->mShowFunc) {
71 if ($this->mEditFunc != $block->mEditFunc) {
75 if ($this->mTemplate != $block->mTemplate) {
82 public function update(&$block)
84 $this->mStatus = LEGACY_INSTALLINFO_STATUS_UPDATED;
86 $this->mName = $block->mName;
87 $this->mFuncFile = $block->mFuncFile;
88 $this->mShowFunc = $block->mShowFunc;
89 $this->mEditFunc = $block->mEditFunc;
90 $this->mTemplate = $block->mTemplate;
97 public $mShowFuncs = [];
98 public $mFuncFiles = [];
100 public function add(&$info)
102 if (isset($this->mBlocks[$info->mFuncNum])) {
106 $this->mBlocks[$info->mFuncNum] =& $info;
107 $this->mShowFuncs[] = $info->mShowFunc;
108 $this->mFuncFiles[] = $info->mFuncFile;
110 ksort($this->mBlocks);
115 public function &
get($funcNum)
117 if (isset($this->mBlocks[$funcNum])) {
118 return $this->mBlocks[$funcNum];
125 public function funcExists($info)
127 return (in_array($info->mShowFunc, $this->mShowFuncs,
true) && in_array($info->mFuncFile, $this->mFuncFiles,
true));
136 foreach (array_keys($this->mBlocks) as $idx) {
137 $t_block =& $collection->get($this->mBlocks[$idx]->mFuncNum);
138 if (
null == $t_block) {
139 if (!$collection->funcExists($this->mBlocks[$idx])) {
140 $this->mBlocks[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_DELETED;
142 $this->mBlocks[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_UPDATED;
144 } elseif (!$this->mBlocks[$idx]->isEqual($t_block)) {
145 $this->mBlocks[$idx]->update($t_block);
149 foreach (array_keys($collection->mBlocks) as $idx) {
150 $func_num = $collection->mBlocks[$idx]->mFuncNum;
151 if (!isset($this->mBlocks[$func_num])) {
152 $this->add($collection->mBlocks[$idx]);
153 $this->mBlocks[$func_num]->mStatus = LEGACY_INSTALLINFO_STATUS_NEW;
158 public function reset()
160 unset($this->mBlocks);
171 public $mStatus = LEGACY_INSTALLINFO_STATUS_LOADED;
179 public $mDescription =
'';
181 public $mFormType =
'';
183 public $mValueType =
'';
185 public $mDefault =
null;
187 public $mOption =
null;
189 public function __construct($name, $title, $description, $formType, $valueType, $default, $order = 0)
191 $this->mName = $name;
192 $this->mTitle = $title;
193 $this->mDescription = $description;
194 $this->mFormType = $formType;
195 $this->mValueType = $valueType;
196 $this->mDefault = $default;
197 $this->mOrder = (int)$order;
208 if ($this->mName != $preference->mName) {
212 if ($this->mTitle != $preference->mTitle) {
216 if ($this->mDescription != $preference->mDescription) {
220 if ($this->mFormType != $preference->mFormType) {
224 if ($this->mValueType != $preference->mValueType) {
228 if ($this->mOrder != $preference->mOrder) {
232 if (!$this->mOption->isEqual($preference->mOption)) {
239 public function update(&$preference)
241 $this->mStatus = LEGACY_INSTALLINFO_STATUS_UPDATED;
243 $this->mName = $preference->mName;
244 $this->mTitle = $preference->mTitle;
245 $this->mDescription = $preference->mDescription;
246 $this->mFormType = $preference->mFormType;
247 $this->mValueType = $preference->mValueType;
248 $this->mDefault = $preference->mDefault;
249 $this->mOrder = $preference->mOrder;
251 unset($this->mOption);
252 $this->mOption =& $preference->mOption;
258 public $mPreferences = [];
260 public $mComments = [];
262 public $mNotifications = [];
264 public function __construct()
268 public function add(&$preference)
270 if (
'com_rule' == $preference->mName ||
'com_anonpost' == $preference->mName) {
271 if (isset($this->mComments[$preference->mName])) {
274 $this->mComments[$preference->mName] =& $preference;
279 if (
'notification_enabled' == $preference->mName ||
'notification_events' == $preference->mName) {
280 if (isset($this->mNotifications[$preference->mName])) {
283 $this->mNotifications[$preference->mName] =& $preference;
288 if (isset($this->mPreferences[$preference->mName])) {
292 $this->mPreferences[$preference->mName] =& $preference;
305 foreach (array_keys($this->mPreferences) as $idx) {
306 if ($this->mPreferences[$idx]->mOrder != $currentOrder) {
307 $this->mPreferences[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_ORDER_UPDATED;
308 $this->mPreferences[$idx]->mOrder = $currentOrder;
314 foreach (array_keys($this->mComments) as $idx) {
315 if ($this->mComments[$idx]->mOrder != $currentOrder) {
316 $this->mComments[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_ORDER_UPDATED;
317 $this->mComments[$idx]->mOrder = $currentOrder;
323 foreach (array_keys($this->mNotifications) as $idx) {
324 if ($this->mNotifications[$idx]->mOrder != $currentOrder) {
325 $this->mNotifications[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_ORDER_UPDATED;
326 $this->mNotifications[$idx]->mOrder = $currentOrder;
333 public function &
get($name)
337 if (isset($this->mPreferences[$name])) {
338 return $this->mPreferences[$name];
344 public function &getNotify($name)
348 if (isset($this->mNotifications[$name])) {
349 return $this->mNotifications[$name];
366 foreach (array_keys($this->mPreferences) as $idx) {
367 $t_preference =& $collection->get($this->mPreferences[$idx]->mName);
368 if (
null == $t_preference) {
369 $this->mPreferences[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_DELETED;
370 } elseif (!$this->mPreferences[$idx]->isEqual($t_preference)) {
371 $this->mPreferences[$idx]->update($t_preference);
375 foreach (array_keys($collection->mPreferences) as $idx) {
376 $name = $collection->mPreferences[$idx]->mName;
377 if (!isset($this->mPreferences[$name])) {
378 $this->add($collection->mPreferences[$name]);
379 $this->mPreferences[$name]->mStatus = LEGACY_INSTALLINFO_STATUS_NEW;
386 if (count($this->mComments) > 0 && 0 == count($collection->mComments)) {
387 foreach (array_keys($this->mComments) as $idx) {
388 $this->mComments[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_DELETED;
390 } elseif (0 == count($this->mComments) && count($collection->mComments) > 0) {
391 $this->mComments =& $collection->mComments;
392 foreach (array_keys($this->mComments) as $idx) {
393 $this->mComments[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_NEW;
400 foreach (array_keys($this->mNotifications) as $idx) {
401 $t_preference =& $collection->getNotify($this->mNotifications[$idx]->mName);
402 if (
null == $t_preference) {
403 $this->mNotifications[$idx]->mStatus = LEGACY_INSTALLINFO_STATUS_DELETED;
404 } elseif (!$this->mNotifications[$idx]->isEqual($t_preference)) {
405 $this->mNotifications[$idx]->update($t_preference);
409 foreach (array_keys($collection->mNotifications) as $idx) {
410 $name = $collection->mNotifications[$idx]->mName;
411 if (!isset($this->mNotifications[$name])) {
412 $this->add($collection->mNotifications[$name]);
413 $this->mNotifications[$name]->mStatus = LEGACY_INSTALLINFO_STATUS_NEW;
418 public function reset()
420 unset($this->mPreferences);
421 $this->mPreferences = [];
509 public function __construct($dirname)
511 $this->_mDirname = $dirname;
523 if (isset($arr[
'class'])) {
524 $showFunc =
'cl::' . $arr[
'class'];
526 $showFunc = $arr[
'show_func'];
530 $editFunc = $arr[
'edit_func'] ??
null;
532 $template = $arr[
'template'] ??
null;
534 $options = $arr[
'options'] ??
null;
536 $info =
new Legacy_BlockInformation($funcNum, $arr[
'name'], $arr[
'file'], $showFunc, $editFunc, $template, $options);
549 $t_filePath = XOOPS_ROOT_PATH .
'/modules/' . $this->_mDirname .
'/xoops_version.php';
550 if (!file_exists($t_filePath)) {
556 if (!isset($modversion[
'blocks'])) {
560 $blockArr = $modversion[
'blocks'];
566 foreach ($blockArr as $idx => $block) {
567 if (isset($block[
'func_num'])) {
569 $successFlag &= $collection->add($info);
572 $successFlag =
false;
584 $collection->reset();
587 foreach ($blockArr as $idx => $block) {
590 $successFlag &= $collection->add($info);
593 $successFlag =
false;
605 $collection->reset();
608 foreach ($blockArr as $block) {
610 $successFlag &= $collection->add($info);
617 public function &_createPreferenceInformation($arr)
620 $arr[
'description'] ??=
null;
621 $info =
new Legacy_PreferenceInformation($arr[
'name'], $arr[
'title'], $arr[
'description'], $arr[
'formtype'], $arr[
'valuetype'], $arr[
'default']);
622 if (isset($arr[
'options'])) {
623 foreach ($arr[
'options'] as $name => $value) {
625 $info->mOption->add($option);
633 public function _loadCommentPreferenceInfomations($modversion, $collection)
635 if (isset($modversion[
'hasComments']) &&
true == $modversion[
'hasComments']) {
636 require_once XOOPS_ROOT_PATH .
'/include/comment_constants.php';
639 'name' =>
'com_rule',
640 'title' =>
'_CM_COMRULES',
642 'formtype' =>
'select',
643 'valuetype' =>
'int',
645 'options' => [
'_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE,
'_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL,
'_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER,
'_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN]
647 $info =& $this->_createPreferenceInformation($comRule);
648 $collection->add($info);
652 'name' =>
'com_anonpost',
653 'title' =>
'_CM_COMANONPOST',
655 'formtype' =>
'yesno',
656 'valuetype' =>
'int',
659 $info =& $this->_createPreferenceInformation($comAnonpost);
660 $collection->add($info);
665 public function _loadNotificationPreferenceInfomations($modversion, $collection)
667 if (isset($modversion[
'hasNotification']) &&
true == $modversion[
'hasNotification']) {
668 require_once XOOPS_ROOT_PATH .
'/include/notification_constants.php';
669 require_once XOOPS_ROOT_PATH .
'/include/notification_functions.php';
672 $t_options[
'_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;
673 $t_options[
'_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;
674 $t_options[
'_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;
675 $t_options[
'_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;
678 'name' =>
'notification_enabled',
679 'title' =>
'_NOT_CONFIG_ENABLE',
680 'description' =>
'_NOT_CONFIG_ENABLEDSC',
681 'formtype' =>
'select',
682 'valuetype' =>
'int',
683 'default' => XOOPS_NOTIFICATION_ENABLEBOTH,
684 'options' => $t_options
686 $info =& $this->_createPreferenceInformation($notifyEnable);
687 $collection->add($info);
694 unset($info, $t_options);
698 $handler =& xoops_gethandler(
'module');
699 $module =& $handler->getByDirname($this->_mDirname);
702 $t_categoryArr =& notificationCategoryInfo(
'', $module->get(
'mid'));
703 foreach ($t_categoryArr as $t_category) {
704 $t_eventArr =& notificationEvents($t_category[
'name'],
false, $module->get(
'mid'));
705 foreach ($t_eventArr as $t_event) {
706 if (!empty($t_event[
'invisible'])) {
709 $t_optionName = $t_category[
'title'] .
' : ' . $t_event[
'title'];
710 $t_options[$t_optionName] = $t_category[
'name'] .
'-' . $t_event[
'name'];
715 'name' =>
'notification_events',
716 'title' =>
'_NOT_CONFIG_EVENTS',
717 'description' =>
'_NOT_CONFIG_EVENTSDSC',
718 'formtype' =>
'select_multi',
719 'valuetype' =>
'array',
720 'default' => array_values($t_options),
721 'options' => $t_options
723 $info =& $this->_createPreferenceInformation($notifyEvents);
724 $collection->add($info);
739 $t_filePath = XOOPS_ROOT_PATH .
'/modules/' . $this->_mDirname .
'/xoops_version.php';
740 if (!file_exists($t_filePath)) {
749 if (!isset($modversion[
'config'])) {
750 $this->_loadCommentPreferenceInfomations($modversion, $collection);
751 $this->_loadNotificationPreferenceInfomations($modversion, $collection);
755 $preferenceArr = $modversion[
'config'];
761 foreach ($preferenceArr as $idx => $preference) {
762 if (is_string($idx)) {
763 $preference[
'name'] = $idx;
764 $info =& $this->_createPreferenceInformation($preference);
765 $successFlag &= $collection->add($info);
768 $successFlag =
false;
777 $collection->reset();
779 foreach ($preferenceArr as $preference) {
780 $info =& $this->_createPreferenceInformation($preference);
781 $collection->add($info);
789 $this->_loadCommentPreferenceInfomations($modversion, $collection);
790 $this->_loadNotificationPreferenceInfomations($modversion, $collection);
803 public function __construct($dirname)
805 $this->_mDirname = $dirname;
808 public function &_createBlockInformation(&$block)
812 $block->get(
'func_num'),
814 $block->get(
'func_file'),
815 $block->get(
'show_func'),
816 $block->get(
'edit_func'),
817 $block->get(
'template'),
818 $block->get(
'options'));
827 $handler =& xoops_getmodulehandler(
'newblocks',
'legacy');
830 $criteria->add(
new Criteria(
'dirname', $this->_mDirname));
831 $criteria->add(
new Criteria(
'block_type',
'M'));
833 $blockArr =& $handler->getObjects($criteria);
835 foreach (array_keys($blockArr) as $idx) {
836 $info =& $this->_createBlockInformation($blockArr[$idx]);
837 while (!$collection->add($info)) {
845 public function &_createPreferenceInformation($config)
847 $info =
new Legacy_PreferenceInformation($config->get(
'conf_name'), $config->get(
'conf_title'), $config->get(
'conf_desc'), $config->get(
'conf_formtype'), $config->get(
'conf_valuetype'), $config->get(
'conf_value'));
849 $configOptionArr =& $config->getOptionItems();
851 foreach (array_keys($configOptionArr) as $idx) {
853 $info->mOption->add($option);
864 $handler =& xoops_gethandler(
'module');
865 $module =& $handler->getByDirname($this->_mDirname);
867 $handler =& xoops_gethandler(
'config');
868 $criteria =
new Criteria(
'conf_modid', $module->get(
'mid'));
869 $criteria->setOrder(
'conf_order');
870 $configArr =& $handler->getConfigs($criteria);
872 foreach (array_keys($configArr) as $idx) {
873 $info =& $this->_createPreferenceInformation($configArr[$idx]);
874 $collection->add($info);