function content_content_display_edit($options)
{
    include_once ICMS_ROOT_PATH . '/modules/' . basename(dirname(dirname(__FILE__))) . '/include/common.php';
    $content_content_handler = icms_getModuleHandler('content', basename(dirname(dirname(__FILE__))), 'content');
    $selpages = new icms_form_elements_Select('', 'options[0]', $options[0]);
    $selpages->addOptionArray($content_content_handler->getContentList());
    $showsubs = new icms_form_elements_Radioyn('', 'options[1]', $options[1]);
    $showbreadc = new icms_form_elements_Radioyn('', 'options[2]', $options[2]);
    $showinfo = new icms_form_elements_Radioyn('', 'options[3]', $options[3]);
    $form = '<table width="100%">';
    $form .= '<tr>';
    $form .= '<td width="30%">' . _MB_CONTENT_CONTENT_SELPAGE . '</td>';
    $form .= '<td>' . $selpages->render() . '</td>';
    $form .= '</tr>';
    $form .= '<tr>';
    $form .= '<td>' . _MB_CONTENT_CONTENT_SHOWSUBS . '</td>';
    $form .= '<td>' . $showsubs->render() . '</td>';
    $form .= '</tr>';
    $form .= '<tr>';
    $form .= '<td>' . _MB_CONTENT_CONTENT_SHOWBREADCRUMB . '</td>';
    $form .= '<td>' . $showbreadc->render() . '</td>';
    $form .= '</tr>';
    $form .= '<tr>';
    $form .= '<td>' . _MB_CONTENT_CONTENT_SHOWINFO . '</td>';
    $form .= '<td>' . $showinfo->render() . '</td>';
    $form .= '</tr>';
    $form .= '</table>';
    return $form;
}
Example #2
0
	/**
	 * Do this event when saving item
	 *
	 * @param array config array
	 */
	function eventAfterSaveSystemAdminPreferencesItems($array) {
		if (!isset($array[ICMS_CONF_AUTOTASKS])) return;
		$handler = icms_getModuleHandler('autotasks', 'system');
		$handler->virtual_config = array();
		$array = &$array[ICMS_CONF_AUTOTASKS];
		$vconfig1 = array();
		$vconfig2 = array();
		foreach ($array as $key => $values) {
			$vconfig1[$key] = $values[0];
			$vconfig2[$key] = $values[1];
		}
		$handler->enableVirtualConfig($vconfig1);
		$system = $handler->getCurrentSystemHandler(true);
		if ($system->isEnabled()) {
			$system->stop();
		}
		$handler->enableVirtualConfig($vconfig2);
		$system = $handler->getCurrentSystemHandler(true);
		if ($rez = $system->canRun()) {
			$time = (int) ($handler->getRealTasksRunningTime());
			$rez = $system->start($time);
		} else {
			icms_loadLanguageFile('system', 'autotasks', true);
			icms_core_Message::error(_CO_ICMS_AUTOTASKS_INIT_ERROR);
			return false;
		}
		$handler->disableVirtualConfig();
	}
Example #3
0
function b_profile_friends_show($options)
{
    global $xoTheme;
    if (!empty(icms::$user)) {
        $profile_friendship_handler = icms_getModuleHandler('friendship', basename(dirname(dirname(__FILE__))), 'profile');
        $friends = $profile_friendship_handler->getFriendships(0, 0, icms::$user->getVar('uid'), 0, PROFILE_FRIENDSHIP_STATUS_ACCEPTED);
        if (count($friends) == 0) {
            return;
        }
        $block = array();
        $i = 0;
        foreach ($friends as $friend) {
            $friend_uid = icms::$user->getVar('uid') == $friend['friend1_uid'] ? $friend['friend2_uid'] : $friend['friend1_uid'];
            $block['friends'][$i]['uname'] = icms_member_user_Handler::getUserLink($friend_uid);
            $block['friends'][$i]['friend_uid'] = $friend_uid;
            $block['friends'][$i]['sort'] = icms_member_user_Object::getUnameFromId($friend_uid);
            $i++;
        }
        if (isset($block['friends']) && count($block['friends']) > 0) {
            usort($block['friends'], 'sortFriendsArray');
        }
        // adding PM javascript, $xoTheme cannot be used in this place because jQuery is not yet loaded
        if (count($block['friends']) > 0) {
            $block['jQuery'] = 'jQuery(document).ready(function(){jQuery("a.block-profile-pm").colorbox({width:600, height:395, iframe:true});});';
        }
    }
    return $block;
}
 /**
  * Delete an object from the database
  * @see icms_ipf_Handler::delete()
  *
  * @param mod_profile_Regstep $obj
  * @param bool $force
  * @return bool
  */
 public function delete(&$obj, $force = false)
 {
     if (parent::delete($obj, $force)) {
         $field_handler = icms_getModuleHandler('field', basename(dirname(dirname(__FILE__))), 'profile');
         return $field_handler->updateAll('step_id', 0, new icms_db_criteria_Item('step_id', $obj->getVar('step_id')));
     }
     return false;
 }
Example #5
0
 function &getFields()
 {
     static $fields_array;
     if (!isset($fields_array)) {
         $profile_handler = icms_getModuleHandler('profile', basename(dirname(dirname(__FILE__))), 'profile');
         $fields_array = $profile_handler->loadFields();
     }
     return $fields_array;
 }
 protected function beforeDelete(&$obj)
 {
     $profile_fields_handler = icms_getModuleHandler('field', basename(dirname(dirname(__FILE__))), 'profile');
     $fields_count = $profile_fields_handler->getCount(icms_buildCriteria(array('catid' => $obj->getVar('catid'))));
     if ($fields_count == 0) {
         return true;
     }
     $obj->setErrors(sprintf(_AM_PROFILE_CATEGORY_NOTDELETED_FIELDS, $fields_count));
     return false;
 }
Example #7
0
 function getCommandLine()
 {
     $atasks_handler =& icms_getModuleHandler('autotasks', 'system');
     $config_atasks =& $atasks_handler->getConfig();
     if (($config_atasks['autotasks_helper_path'] = trim($config_atasks['autotasks_helper_path'])) != '') {
         if (substr($config_atasks['autotasks_helper_path'], -1) != '\\') {
             $config_atasks['autotasks_helper_path'] .= '\\';
         }
     }
     return (isset($_SERVER['COMSPEC']) ? $_SERVER['COMSPEC'] : $_SERVER['ComSpec']) . ' /C ' . str_replace(array('\\/', '/\\', '/'), array('/', '\\', '\\'), '"' . $config_atasks['autotasks_helper_path'] . str_replace(array('%path%', '%url%'), array(str_replace('/', '\\', ICMS_ROOT_PATH . '/include/autotasks.php'), ICMS_URL . '/include/autotasks.php'), $config_atasks['autotasks_helper']) . ' > NUL"');
 }
Example #8
0
	/**
	 * Function to be triggered at the end of the output init process
	 *
	 * @return	void
	 */
	public function eventStartOutputInit() {
		global $icmsTpl;
		$icms_adsense_handler = icms_getModuleHandler("adsense", "system");
		$icms_adsensesObj = $icms_adsense_handler->getAdsensesByTag();
		$adsenses_array = array();
		if (is_object($icmsTpl)) {
			foreach ($icms_adsensesObj as $k => $v) {
				$adsenses_array[$k] = $v->render();
			}
			$icmsTpl->assign('icmsAdsenses', $adsenses_array);
		}
	}
Example #9
0
	/**
	 * Function to be triggered at the end of the output init process
	 *
	 * @return	void
	 */
	function eventStartOutputInit() {
		global $icmsTpl;
		$icms_customtag_handler = icms_getModuleHandler("customtag", "system");
		$icms_customTagsObj = $icms_customtag_handler->getCustomtagsByName();
		$customtags_array = array();
		if (is_object($icmsTpl)) {
			foreach ($icms_customTagsObj as $k => $v) {
				$customtags_array[$k] = $v->render();
			}
			$icmsTpl->assign("icmsCustomtags", $customtags_array);
		}
	}
Example #10
0
function b_waiting_catads()
{
    $block = array();
    $ads_hnd =& icms_getModuleHandler('ads', 'catads');
    $criteria = new icms_db_criteria_Item('waiting', '1', '=');
    $nbads = $ads_hnd->getCount($criteria);
    if ($nbads > 0) {
        $block['adminlink'] = ICMS_URL . "/modules/catads/admin/index.php?action=waiting";
        $block['pendingnum'] = $nbads;
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
    }
    return $block;
}
function billboard_slides_show()
{
    include_once ICMS_ROOT_PATH . '/modules/billboard/include/common.php';
    $billboard_slide_handler = icms_getModuleHandler('slide', 'billboard');
    $billboard_config = icms_getModuleConfig('billboard');
    $criteria = new CriteriaCompo();
    $criteria->setStart(0);
    $criteria->setLimit(10);
    $criteria->setSort('slide_order');
    $criteria->setOrder('ASC');
    $block = array();
    $block['slides'] = $billboard_slide_handler->getObjects($criteria, true, false);
    $block['config'] = $billboard_config;
    return $block;
}
Example #12
0
function content_search($queryarray, $andor, $limit, $offset, $userid)
{
    $imcontent_content_handler = icms_getModuleHandler('content', basename(dirname(dirname(__FILE__))), 'content');
    $contentsArray = $imcontent_content_handler->getContentsForSearch($queryarray, $andor, $limit, $offset, $userid);
    $ret = array();
    foreach ($contentsArray as $contentArray) {
        $item['image'] = "images/content.png";
        $item['link'] = $contentArray['itemUrl'];
        $item['title'] = $contentArray['content_title'];
        $item['time'] = strtotime($contentArray['content_published_date']);
        $item['uid'] = $contentArray['content_posterid'];
        $ret[] = $item;
        unset($item);
    }
    return $ret;
}
Example #13
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $control = $object->getControl($key);
     if (isset($control['delimeter'])) {
         $this->_delimeter = $control['delimeter'];
     }
     parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'), $this->_delimeter);
     // Adding the options inside this Radio element
     // If the custom method is not from a module, than it's from the core
     if (isset($control['options'])) {
         $this->addOptionArray($control['options']);
     } else {
         // let's find out if the method we need to call comes from an already defined object
         if (isset($control['object'])) {
             if (method_exists($control['object'], $control['method'])) {
                 if ($option_array = $control['object']->{$control}['method']()) {
                     // Adding the options array to the Radio element
                     $this->addOptionArray($option_array);
                 }
             }
         } else {
             // finding the itemHandler; if none, let's take the itemHandler of the $object
             if (isset($control['itemHandler'])) {
                 if (!$control['module']) {
                     // Creating the specified core object handler
                     $control_handler = icms::handler($control['itemHandler']);
                 } else {
                     $control_handler =& icms_getModuleHandler($control['itemHandler'], $control['module']);
                 }
             } else {
                 $control_handler =& $object->handler;
             }
             // Checking if the specified method exists
             if (method_exists($control_handler, $control['method'])) {
                 // TODO : How could I pass the parameters in the following call ...
                 if ($option_array = $control_handler->{$control}['method']()) {
                     // Adding the options array to the Radio element
                     $this->addOptionArray($option_array);
                 }
             }
         }
     }
 }
Example #14
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $size = isset($var['size']) ? $var['size'] : ($this->_multiple ? 5 : 1);
     // Adding the options inside this SelectBox
     // If the custom method is not from a module, than it's from the core
     $control = $object->getControl($key);
     $value = isset($control['value']) ? $control['value'] : $object->getVar($key, 'e');
     parent::__construct($var['form_caption'], $key, $value, $size, $this->_multiple);
     if (isset($control['options'])) {
         $this->addOptionArray($control['options']);
     } else {
         // let's find if the method we need to call comes from an already defined object
         if (isset($control['object'])) {
             if (method_exists($control['object'], $control['method'])) {
                 if ($option_array = $control['object']->{$control}['method']()) {
                     // Adding the options array to the select element
                     $this->addOptionArray($option_array);
                 }
             }
         } else {
             // finding the itemHandler; if none, let's take the itemHandler of the $object
             if (isset($control['itemHandler'])) {
                 if (!isset($control['module'])) {
                     // Creating the specified core object handler
                     $control_handler = icms::handler($control['itemHandler']);
                 } else {
                     $control_handler =& icms_getModuleHandler($control['itemHandler'], $control['module']);
                 }
             } else {
                 $control_handler =& $object->handler;
             }
             // Checking if the specified method exists
             if (method_exists($control_handler, $control['method'])) {
                 $option_array = call_user_func_array(array($control_handler, $control['method']), isset($control['params']) ? $control['params'] : array());
                 if (is_array($option_array) && count($option_array) > 0) {
                     // Adding the options array to the select element
                     $this->addOptionArray($option_array);
                 }
             }
         }
     }
 }
Example #15
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $control = $object->getControl($key);
     if (isset($control['delimeter'])) {
         $this->_delimeter = $control['delimeter'];
     }
     parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key), $this->_delimeter);
     if (isset($control['options'])) {
         $this->addOptionArray($control['options']);
     } else {
         // let's find if the method we need to call comes from an already defined object
         if (isset($control['object'])) {
             if (method_exists($control['object'], $control['method'])) {
                 if ($option_array = $control['object']->{$control}['method']()) {
                     // Adding the options array to the select element
                     $this->addOptionArray($option_array);
                 }
             }
         } else {
             // finding the itemHandler; if none, let's take the itemHandler of the $object
             if (isset($control['itemHandler'])) {
                 if (!isset($control['module'])) {
                     // Creating the specified core object handler
                     $control_handler = icms::handler($control['itemHandler']);
                 } else {
                     $control_handler =& icms_getModuleHandler($control['itemHandler'], $control['module']);
                 }
             } else {
                 $control_handler =& $object->handler;
             }
             // Checking if the specified method exists
             if (method_exists($control_handler, $control['method'])) {
                 $option_array = call_user_func_array(array($control_handler, $control['method']), isset($control['params']) ? $control['params'] : array());
                 if (is_array($option_array) && count($option_array) > 0) {
                     // Adding the options array to the select element
                     $this->addOptionArray($option_array);
                 }
             }
         }
     }
 }
Example #16
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $category_title_field = $object->handler->identifierName;
     $addNoParent = isset($object->controls[$key]['addNoParent']) ? $object->controls[$key]['addNoParent'] : true;
     $criteria = new icms_db_criteria_Compo();
     $criteria->setSort("weight, " . $category_title_field);
     $category_handler = icms_getModuleHandler('category', $object->handler->_moduleName);
     $categories = $category_handler->getObjects($criteria);
     $mytree = new icms_ipf_Tree($categories, "category_id", "category_pid");
     parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e'));
     $ret = array();
     $options = $this->getOptionArray($mytree, $category_title_field, 0, $ret, "");
     if ($addNoParent) {
         $newOptions = array('0' => '----');
         foreach ($options as $k => $v) {
             $newOptions[$k] = $v;
         }
         $options = $newOptions;
     }
     $this->addOptionArray($options);
 }
Example #17
0
/**
 * Return search results and show images on userinfo page
 *
 * @param array $queryarray the terms to look
 * @param text $andor the conector between the terms to be looked
 * @param int $limit The number of maximum results
 * @param int $offset from wich register start
 * @param int $userid from which user to look
 * @return array $ret with all results
 */
function profile_search($queryarray, $andor, $limit, $offset, $userid)
{
    global $icmsConfigUser;
    $ret = array();
    $i = 0;
    $dirname = basename(dirname(dirname(__FILE__)));
    // check if anonymous users can access profiles
    if (!is_object(icms::$user) && !$icmsConfigUser['allow_annon_view_prof']) {
        return $ret;
    }
    // check if tribes are activated in module configuration
    $module = icms::handler('icms_module')->getByDirname($dirname, TRUE);
    if (!$module->config['enable_tribes']) {
        return $ret;
    }
    $profile_tribes_handler = icms_getModuleHandler('tribes', basename(dirname(dirname(__FILE__))), 'profile');
    $criteria = new icms_db_criteria_Compo();
    // if those two lines are uncommented, "all search results" isn't showing in the search results
    //if ($offset) $criteria->setStart($offset);
    //if ($limit) $criteria->setLimit((int)$limit);
    $criteria->setSort('title');
    if ($userid) {
        $criteria->add(new icms_db_criteria_Item('uid_owner', $userid));
    }
    if (is_array($queryarray) && count($queryarray) > 0) {
        foreach ($queryarray as $query) {
            $criteria_query = new icms_db_criteria_Compo();
            $criteria_query->add(new icms_db_criteria_Item('title', '%' . $query . '%', 'LIKE'));
            $criteria_query->add(new icms_db_criteria_Item('tribe_desc', '%' . $query . '%', 'LIKE'), 'OR');
            $criteria->add($criteria_query, $andor);
            unset($criteria_query);
        }
    }
    $tribes = $profile_tribes_handler->getObjects($criteria, false, false);
    foreach ($tribes as $tribe) {
        $ret[$i++] = array("image" => 'images/tribes.gif', "link" => $tribe['itemUrl'], "title" => $tribe['title'], "time" => strtotime($tribe['creation_time']), "uid" => $tribe['uid_owner']);
    }
    return $ret;
}
function profile_iteminfo($category, $item_id)
{
    $item = array('name' => '', 'url' => '');
    switch ($category) {
        case 'pictures':
        case 'videos':
        case 'audio':
            $thisUser = icms::handler('icms_member')->getUser($item_id);
            if ($thisUser === false) {
                break;
            }
            $item['name'] = $thisUser->getVar('uname');
            $item['url'] = ICMS_URL . '/modules/' . basename(dirname(dirname(__FILE__))) . '/' . $category . '.php?uid=' . $item_id;
            break;
        case 'tribetopic':
            $profile_tribes_handler = icms_getModuleHandler('tribes', basename(dirname(dirname(__FILE__))), 'profile');
            $tribesObj = $profile_tribes_handler->get($item_id);
            if ($tribesObj->isNew()) {
                break;
            }
            $item['name'] = $tribesObj->getVar('title');
            $item['url'] = $tribesObj->getItemLink(true);
            break;
        case 'tribepost':
            $profile_tribetopic_handler = icms_getModuleHandler('tribetopic', basename(dirname(dirname(__FILE__))), 'profile');
            $tribetopicObj = $profile_tribetopic_handler->get($item_id);
            if ($tribetopicObj->isNew()) {
                break;
            }
            $tribetopic = $tribetopicObj->toArray();
            $item['name'] = $tribetopic['title'];
            $item['url'] = $tribetopic['itemUrl'];
            break;
    }
    return $item;
}
Example #19
0
}
$clean_tribeuser_id = isset($_GET['tribeuser_id']) ? (int) $_GET['tribeuser_id'] : 0;
/** Create a whitelist of valid values, be sure to use appropriate types for each value
 * Be sure to include a value for no parameter, if you have a default condition
 */
$valid_op = array('mod', 'addtribeuser', 'del', '');
/**
 * in_array() is a native PHP function that will determine if the value of the
 * first argument is found in the array listed in the second argument. Strings
 * are case sensitive and the 3rd argument determines whether type matching is
 * required
 */
if (in_array($clean_op, $valid_op, true)) {
    switch ($clean_op) {
        case "mod":
            $profile_tribes_handler = icms_getModuleHandler('tribes', basename(dirname(dirname(__FILE__))), 'profile');
            $tribes = $profile_tribes_handler->getAllTribes();
            if (count($tribes) == 0) {
                redirect_header(PROFILE_ADMIN_URL . 'tribeuser.php', 3, _AM_PROFILE_TRIBEUSER_NOTTRIBESYET);
            }
            icms_cp_header();
            edittribeuser($clean_tribeuser_id);
            break;
        case "addtribeuser":
            $controller = new icms_ipf_Controller($profile_tribeuser_handler);
            $controller->storeFromDefaultForm(_AM_PROFILE_TRIBEUSER_CREATED, _AM_PROFILE_TRIBEUSER_MODIFIED);
            break;
        case "del":
            $controller = new icms_ipf_Controller($profile_tribeuser_handler);
            $controller->handleObjectDeletion();
            break;
Example #20
0
/**
 * Shows the form to edit the top posters
 *
 * @param array $options The block options
 * @return string $form The edit top posters form HTML string
 */
function b_system_topposters_edit($options) {
	$inputtag = "<input type='text' name='options[]' value='". (int) $options[0] . "' />";
	$form = sprintf(_MB_SYSTEM_DISPLAY, $inputtag);
	$form .= "<br />" . _MB_SYSTEM_DISPLAYA . "&nbsp;<input type='radio' id='options[]' name='options[]' value='1'";
	if ($options[1] == 1) {
		$form .= " checked='checked'";
	}
	$form .= " />&nbsp;" . _YES . "<input type='radio' id='options[]' name='options[]' value='0'";
	if ($options[1] == 0) {
		$form .= " checked='checked'";
	}
	$form .= " />&nbsp;" . _NO . "";
	$form .= "<br />" . _MB_SYSTEM_NODISPGR . "<br /><select id='options[]' name='options[]' multiple='multiple'>";
	$ranks = icms_getModuleHandler("userrank", "system")->getList(icms_buildCriteria(array('rank_special' => '1')));
	$size = count($options);
	foreach ($ranks as $k => $v) {
		$sel = "";
		for ($i = 2; $i < $size; $i++) {
			if ($k == $options[$i]) {
				$sel = " selected='selected'";
			}
		}
		$form .= "<option value='$k'$sel>$v</option>";
	}
	$form .= "</select>";
	return $form;
}
Example #21
0
function icms_module_update($dirname)
{
    $dirname = trim($dirname);
    $db =& icms_db_Factory::instance();
    $module_handler = icms::handler('icms_module');
    $module =& $module_handler->getByDirname($dirname);
    // Save current version for use in the update function
    $prev_version = $module->getVar('version');
    $prev_dbversion = $module->getVar('dbversion');
    xoops_template_clear_module_cache($module->getVar('mid'));
    // we dont want to change the module name set by admin
    $temp_name = $module->getVar('name');
    $module->loadInfoAsVar($dirname);
    $module->setVar('name', $temp_name);
    if (!$module_handler->insert($module)) {
        echo '<p>Could not update ' . $module->getVar('name') . '</p>';
        echo "<br /><a href='admin.php?fct=modulesadmin'>" . _MD_AM_BTOMADMIN . "</a>";
    } else {
        $newmid = $module->getVar('mid');
        $msgs = array();
        $msgs[] = _MD_AM_MOD_DATA_UPDATED;
        $tplfile_handler =& icms::handler('icms_view_template_file');
        $deltpl =& $tplfile_handler->find('default', 'module', $module->getVar('mid'));
        $delng = array();
        if (is_array($deltpl)) {
            $xoopsDelTpl = new icms_view_Tpl();
            // clear cache files
            $xoopsDelTpl->clear_cache(null, 'mod_' . $dirname);
            // delete template file entry in db
            $dcount = count($deltpl);
            for ($i = 0; $i < $dcount; $i++) {
                if (!$tplfile_handler->delete($deltpl[$i])) {
                    $delng[] = $deltpl[$i]->getVar('tpl_file');
                }
            }
        }
        $templates = $module->getInfo('templates');
        if ($templates != false) {
            $msgs[] = _MD_AM_MOD_UP_TEM;
            foreach ($templates as $tpl) {
                $tpl['file'] = trim($tpl['file']);
                if (!in_array($tpl['file'], $delng)) {
                    $tpldata =& xoops_module_gettemplate($dirname, $tpl['file']);
                    $tplfile =& $tplfile_handler->create();
                    $tplfile->setVar('tpl_refid', $newmid);
                    $tplfile->setVar('tpl_lastimported', 0);
                    $tplfile->setVar('tpl_lastmodified', time());
                    if (preg_match("/\\.css\$/i", $tpl['file'])) {
                        $tplfile->setVar('tpl_type', 'css');
                    } else {
                        $tplfile->setVar('tpl_type', 'module');
                    }
                    $tplfile->setVar('tpl_source', $tpldata, true);
                    $tplfile->setVar('tpl_module', $dirname);
                    $tplfile->setVar('tpl_tplset', 'default');
                    $tplfile->setVar('tpl_file', $tpl['file'], true);
                    $tplfile->setVar('tpl_desc', $tpl['description'], true);
                    if (!$tplfile_handler->insert($tplfile)) {
                        $msgs[] = sprintf('&nbsp;&nbsp;<span style="color:#ff0000;">' . _MD_AM_TEMPLATE_INSERT_FAIL . '</span>', '<strong>' . $tpl['file'] . '</strong>');
                    } else {
                        $newid = $tplfile->getVar('tpl_id');
                        $msgs[] = sprintf('&nbsp;&nbsp;<span>' . _MD_AM_TEMPLATE_INSERTED . '</span>', '<strong>' . $tpl['file'] . '</strong>', '<strong>' . $newid . '</strong>');
                        if ($icmsConfig['template_set'] == 'default') {
                            if (!icms_view_Tpl::template_touch($newid)) {
                                $msgs[] = sprintf('&nbsp;&nbsp;<span style="color:#ff0000;">' . _MD_AM_TEMPLATE_RECOMPILE_FAIL . '</span>', '<strong>' . $tpl['file'] . '</strong>');
                            } else {
                                $msgs[] = sprintf('&nbsp;&nbsp;<span>' . _MD_AM_TEMPLATE_RECOMPILED . '</span>', '<strong>' . $tpl['file'] . '</strong>');
                            }
                        }
                    }
                    unset($tpldata);
                } else {
                    $msgs[] = sprintf('&nbsp;&nbsp;<span style="color:#ff0000;">' . _MD_AM_TEMPLATE_DELETE_FAIL . '</span>', $tpl['file']);
                }
            }
        }
        $blocks = $module->getInfo('blocks');
        $msgs[] = _MD_AM_MOD_REBUILD_BLOCKS;
        if ($blocks != false) {
            $count = count($blocks);
            $showfuncs = array();
            $funcfiles = array();
            for ($i = 1; $i <= $count; $i++) {
                if (isset($blocks[$i]['show_func']) && $blocks[$i]['show_func'] != '' && isset($blocks[$i]['file']) && $blocks[$i]['file'] != '') {
                    $editfunc = isset($blocks[$i]['edit_func']) ? $blocks[$i]['edit_func'] : '';
                    $showfuncs[] = $blocks[$i]['show_func'];
                    $funcfiles[] = $blocks[$i]['file'];
                    $template = '';
                    if (isset($blocks[$i]['template']) && trim($blocks[$i]['template']) != '') {
                        $content =& xoops_module_gettemplate($dirname, $blocks[$i]['template'], true);
                    }
                    if (!$content) {
                        $content = '';
                    } else {
                        $template = $blocks[$i]['template'];
                    }
                    $options = '';
                    if (!empty($blocks[$i]['options'])) {
                        $options = $blocks[$i]['options'];
                    }
                    $sql = "SELECT bid, name FROM " . $db->prefix('newblocks') . " WHERE mid='" . (int) $module->getVar('mid') . "' AND func_num='" . (int) $i . "' AND show_func='" . addslashes($blocks[$i]['show_func']) . "' AND func_file='" . addslashes($blocks[$i]['file']) . "'";
                    $fresult = $db->query($sql);
                    $fcount = 0;
                    while ($fblock = $db->fetchArray($fresult)) {
                        $fcount++;
                        $sql = "UPDATE " . $db->prefix("newblocks") . " SET name='" . addslashes($blocks[$i]['name']) . "', edit_func='" . addslashes($editfunc) . "', content='', template='" . $template . "', last_modified=" . time() . " WHERE bid='" . (int) $fblock['bid'] . "'";
                        $result = $db->query($sql);
                        if (!$result) {
                            $msgs[] = sprintf('&nbsp;&nbsp;' . _MD_AM_UPDATE_FAIL, $fblock['name']);
                        } else {
                            $msgs[] = sprintf('&nbsp;&nbsp;' . _MD_AM_BLOCK_UPDATED, '<strong>' . $fblock['name'] . '</strong>', '<strong>' . icms_conv_nr2local($fblock['bid']) . '</strong>');
                            if ($template != '') {
                                $tplfile =& $tplfile_handler->find('default', 'block', $fblock['bid']);
                                if (count($tplfile) == 0) {
                                    $tplfile_new =& $tplfile_handler->create();
                                    $tplfile_new->setVar('tpl_module', $dirname);
                                    $tplfile_new->setVar('tpl_refid', (int) $fblock['bid']);
                                    $tplfile_new->setVar('tpl_tplset', 'default');
                                    $tplfile_new->setVar('tpl_file', $blocks[$i]['template'], true);
                                    $tplfile_new->setVar('tpl_type', 'block');
                                } else {
                                    $tplfile_new = $tplfile[0];
                                }
                                $tplfile_new->setVar('tpl_source', $content, true);
                                $tplfile_new->setVar('tpl_desc', $blocks[$i]['description'], true);
                                $tplfile_new->setVar('tpl_lastmodified', time());
                                $tplfile_new->setVar('tpl_lastimported', 0);
                                if (!$tplfile_handler->insert($tplfile_new)) {
                                    $msgs[] = sprintf('&nbsp;&nbsp;<span style="color:#ff0000;">' . _MD_AM_TEMPLATE_UPDATE_FAIL . '</span>', '<strong>' . $blocks[$i]['template'] . '</strong>');
                                } else {
                                    $msgs[] = '&nbsp;&nbsp;Template <b>' . $blocks[$i]['template'] . '</b> updated.';
                                    if ($icmsConfig['template_set'] == 'default') {
                                        if (!icms_view_Tpl::template_touch($tplfile_new->getVar('tpl_id'))) {
                                            $msgs[] = sprintf('&nbsp;&nbsp;<span style="color:#ff0000;">' . _MD_AM_TEMPLATE_RECOMPILE_FAIL . '</span>', '<strong>' . $blocks[$i]['template'] . '</strong>');
                                        } else {
                                            $msgs[] = sprintf('&nbsp;&nbsp;' . _MD_AM_TEMPLATE_RECOMPILED, '<strong>' . $blocks[$i]['template'] . '</strong>');
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($fcount == 0) {
                        $newbid = $db->genId($db->prefix('newblocks') . '_bid_seq');
                        $block_name = addslashes($blocks[$i]['name']);
                        $sql = "INSERT INTO " . $db->prefix("newblocks") . " (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, c_type, isactive, dirname, func_file, show_func, edit_func, template, bcachetime, last_modified) VALUES ('" . (int) $newbid . "', '" . (int) $module->getVar('mid') . "', '" . (int) $i . "','" . addslashes($options) . "','" . $block_name . "', '" . $block_name . "', '', '1', '0', '0', 'M', 'H', '1', '" . addslashes($dirname) . "', '" . addslashes($blocks[$i]['file']) . "', '" . addslashes($blocks[$i]['show_func']) . "', '" . addslashes($editfunc) . "', '" . $template . "', '0', '" . time() . "')";
                        $result = $db->query($sql);
                        if (!$result) {
                            $msgs[] = '&nbsp;&nbsp;ERROR: Could not create ' . $blocks[$i]['name'];
                            echo $sql;
                        } else {
                            if (empty($newbid)) {
                                $newbid = $db->getInsertId();
                            }
                            $groups =& icms::$user->getGroups();
                            $gperm_handler = icms::handler('icms_member_groupperm');
                            foreach ($groups as $mygroup) {
                                $bperm =& $gperm_handler->create();
                                $bperm->setVar('gperm_groupid', (int) $mygroup);
                                $bperm->setVar('gperm_itemid', (int) $newbid);
                                $bperm->setVar('gperm_name', 'block_read');
                                $bperm->setVar('gperm_modid', 1);
                                if (!$gperm_handler->insert($bperm)) {
                                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not add block access right. Block ID: <b>' . $newbid . '</b> Group ID: <b>' . $mygroup . '</b></span>';
                                } else {
                                    $msgs[] = '&nbsp;&nbsp;Added block access right. Block ID: <b>' . $newbid . '</b> Group ID: <b>' . $mygroup . '</b>';
                                }
                            }
                            if ($template != '') {
                                $tplfile =& $tplfile_handler->create();
                                $tplfile->setVar('tpl_module', $dirname);
                                $tplfile->setVar('tpl_refid', (int) $newbid);
                                $tplfile->setVar('tpl_source', $content, true);
                                $tplfile->setVar('tpl_tplset', 'default');
                                $tplfile->setVar('tpl_file', $blocks[$i]['template'], true);
                                $tplfile->setVar('tpl_type', 'block');
                                $tplfile->setVar('tpl_lastimported', 0);
                                $tplfile->setVar('tpl_lastmodified', time());
                                $tplfile->setVar('tpl_desc', $blocks[$i]['description'], true);
                                if (!$tplfile_handler->insert($tplfile)) {
                                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not insert template <b>' . $blocks[$i]['template'] . '</b> to the database.</span>';
                                } else {
                                    $newid = $tplfile->getVar('tpl_id');
                                    $msgs[] = '&nbsp;&nbsp;Template <b>' . $blocks[$i]['template'] . '</b> added to the database.';
                                    if ($icmsConfig['template_set'] == 'default') {
                                        if (!icms_view_Tpl::template_touch($newid)) {
                                            $msgs[] = sprintf('&nbsp;&nbsp;<span style="color:#ff0000;">' . _MD_AM_TEMPLATE_RECOMPILE_FAIL . '</span>', '<strong>' . $blocks[$i]['template'] . '</strong>');
                                        } else {
                                            $msgs[] = sprintf('&nbsp;&nbsp;' . _MD_AM_TEMPLATE_RECOMPILED, '<strong>' . $blocks[$i]['template'] . '</strong>');
                                        }
                                    }
                                }
                            }
                            $msgs[] = '&nbsp;&nbsp;Block <b>' . $blocks[$i]['name'] . '</b> created. Block ID: <b>' . $newbid . '</b>';
                            $sql = "INSERT INTO " . $db->prefix('block_module_link') . " (block_id, module_id, page_id) VALUES ('" . (int) $newbid . "', '0', '1')";
                            $db->query($sql);
                        }
                    }
                }
            }
            $icms_block_handler = icms::handler('icms_view_block');
            $block_arr = $icms_block_handler->getByModule($module->getVar('mid'));
            foreach ($block_arr as $block) {
                if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) {
                    $sql = sprintf("DELETE FROM %s WHERE bid = '%u'", $db->prefix('newblocks'), (int) $block->getVar('bid'));
                    if (!$db->query($sql)) {
                        $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not delete block <b>' . $block->getVar('name') . '</b>. Block ID: <b>' . $block->getVar('bid') . '</b></span>';
                    } else {
                        $msgs[] = '&nbsp;&nbsp;Block <b>' . $block->getVar('name') . ' deleted. Block ID: <b>' . $block->getVar('bid') . '</b>';
                        if ($block->getVar('template') != '') {
                            $tplfiles =& $tplfile_handler->find(null, 'block', $block->getVar('bid'));
                            if (is_array($tplfiles)) {
                                $btcount = count($tplfiles);
                                for ($k = 0; $k < $btcount; $k++) {
                                    if (!$tplfile_handler->delete($tplfiles[$k])) {
                                        $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not remove deprecated block template. (ID: <b>' . $tplfiles[$k]->getVar('tpl_id') . '</b>)</span>';
                                    } else {
                                        $msgs[] = '&nbsp;&nbsp;Block template <b>' . $tplfiles[$k]->getVar('tpl_file') . '</b> deprecated.';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // first delete all config entries
        $config_handler = icms::handler('icms_config');
        $configs =& $config_handler->getConfigs(new icms_db_criteria_Item('conf_modid', $module->getVar('mid')));
        $confcount = count($configs);
        $config_delng = array();
        if ($confcount > 0) {
            $msgs[] = 'Deleting module config options...';
            for ($i = 0; $i < $confcount; $i++) {
                if (!$config_handler->deleteConfig($configs[$i])) {
                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not delete config data from the database. Config ID: <b>' . $configs[$i]->getvar('conf_id') . '</b></span>';
                    // save the name of config failed to delete for later use
                    $config_delng[] = $configs[$i]->getvar('conf_name');
                } else {
                    $config_old[$configs[$i]->getvar('conf_name')]['value'] = $configs[$i]->getvar('conf_value', 'N');
                    $config_old[$configs[$i]->getvar('conf_name')]['formtype'] = $configs[$i]->getvar('conf_formtype');
                    $config_old[$configs[$i]->getvar('conf_name')]['valuetype'] = $configs[$i]->getvar('conf_valuetype');
                    $msgs[] = '&nbsp;&nbsp;Config data deleted from the database. Config ID: <b>' . $configs[$i]->getVar('conf_id') . '</b>';
                }
            }
        }
        // now reinsert them with the new settings
        $configs = $module->getInfo('config');
        if ($configs != false) {
            if ($module->getVar('hascomments') != 0) {
                include_once ICMS_ROOT_PATH . '/include/comment_constants.php';
                array_push($configs, array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)));
                array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0));
            }
        } else {
            if ($module->getVar('hascomments') != 0) {
                $configs = array();
                include_once ICMS_ROOT_PATH . '/include/comment_constants.php';
                $configs[] = array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN));
                $configs[] = array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0);
            }
        }
        // RMV-NOTIFY
        if ($module->getVar('hasnotification') != 0) {
            if (empty($configs)) {
                $configs = array();
            }
            // Main notification options
            include_once ICMS_ROOT_PATH . '/include/notification_constants.php';
            include_once ICMS_ROOT_PATH . '/include/notification_functions.php';
            $options = array();
            $options['_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;
            $options['_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;
            $options['_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;
            $options['_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;
            //$configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLED', 'description' => '_NOT_CONFIG_ENABLEDDSC', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1);
            $configs[] = array('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLE', 'description' => '_NOT_CONFIG_ENABLEDSC', 'formtype' => 'select', 'valuetype' => 'int', 'default' => XOOPS_NOTIFICATION_ENABLEBOTH, 'options' => $options);
            // Event specific notification options
            // FIXME: for some reason the default doesn't come up properly
            //  initially is ok, but not when 'update' module..
            $options = array();
            $categories =& icms_data_notification_Handler::categoryInfo('', $module->getVar('mid'));
            foreach ($categories as $category) {
                $events =& icms_data_notification_Handler::categoryEvents($category['name'], false, $module->getVar('mid'));
                foreach ($events as $event) {
                    if (!empty($event['invisible'])) {
                        continue;
                    }
                    $option_name = $category['title'] . ' : ' . $event['title'];
                    $option_value = $category['name'] . '-' . $event['name'];
                    $options[$option_name] = $option_value;
                    //$configs[] = array ('name' => icms_data_notification_Handler::generateConfig($category,$event,'name'), 'title' => icms_data_notification_Handler::generateConfig($category,$event,'title_constant'), 'description' => icms_data_notification_Handler::generateConfig($category,$event,'description_constant'), 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1);
                }
            }
            $configs[] = array('name' => 'notification_events', 'title' => '_NOT_CONFIG_EVENTS', 'description' => '_NOT_CONFIG_EVENTSDSC', 'formtype' => 'select_multi', 'valuetype' => 'array', 'default' => array_values($options), 'options' => $options);
        }
        if ($configs != false) {
            $msgs[] = 'Adding module config data...';
            $config_handler = icms::handler('icms_config');
            $order = 0;
            foreach ($configs as $config) {
                // only insert ones that have been deleted previously with success
                if (!in_array($config['name'], $config_delng)) {
                    $confobj =& $config_handler->createConfig();
                    $confobj->setVar('conf_modid', (int) $newmid);
                    $confobj->setVar('conf_catid', 0);
                    $confobj->setVar('conf_name', $config['name']);
                    $confobj->setVar('conf_title', $config['title'], true);
                    $confobj->setVar('conf_desc', $config['description'], true);
                    $confobj->setVar('conf_formtype', $config['formtype']);
                    $confobj->setVar('conf_valuetype', $config['valuetype']);
                    if (isset($config_old[$config['name']]['value']) && $config_old[$config['name']]['formtype'] == $config['formtype'] && $config_old[$config['name']]['valuetype'] == $config['valuetype']) {
                        // preserver the old value if any
                        // form type and value type must be the same
                        $confobj->setVar('conf_value', $config_old[$config['name']]['value'], true);
                    } else {
                        $confobj->setConfValueForInput($config['default'], true);
                        //$confobj->setVar('conf_value', $config['default'], true);
                    }
                    $confobj->setVar('conf_order', $order);
                    $confop_msgs = '';
                    if (isset($config['options']) && is_array($config['options'])) {
                        foreach ($config['options'] as $key => $value) {
                            $confop =& $config_handler->createConfigOption();
                            $confop->setVar('confop_name', $key, true);
                            $confop->setVar('confop_value', $value, true);
                            $confobj->setConfOptions($confop);
                            $confop_msgs .= '<br />&nbsp;&nbsp;&nbsp;&nbsp;Config option added. Name: <b>' . $key . '</b> Value: <b>' . $value . '</b>';
                            unset($confop);
                        }
                    }
                    $order++;
                    if (false != $config_handler->insertConfig($confobj)) {
                        $msgs[] = '&nbsp;&nbsp;Config <b>' . $config['name'] . '</b> added to the database.' . $confop_msgs;
                    } else {
                        $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not insert config <b>' . $config['name'] . '</b> to the database.</span>';
                    }
                    unset($confobj);
                }
            }
            unset($configs);
        }
        // add module specific tasks to system autotasks list
        $atasks = $module->getInfo('autotasks');
        $atasks_handler =& icms_getModuleHandler('autotasks', 'system');
        if (count($atasks) > 0) {
            $msgs[] = 'Updating autotasks...';
            $criteria = new icms_db_criteria_Compo();
            $criteria->add(new icms_db_criteria_Item('sat_type', 'addon/' . $module->getInfo('dirname')));
            $items_atasks = $atasks_handler->getObjects($criteria, false);
            foreach ($items_atasks as $task) {
                $taskID = (int) $task->getVar('sat_addon_id');
                $atasks[$taskID]['enabled'] = $task->getVar('sat_enabled');
                $atasks[$taskID]['repeat'] = $task->getVar('sat_repeat');
                $atasks[$taskID]['interval'] = $task->getVar('sat_interval');
                $atasks[$taskID]['name'] = $task->getVar('sat_name');
            }
            $atasks_handler->deleteAll($criteria);
            foreach ($atasks as $taskID => $taskData) {
                if (!isset($taskData['code']) || trim($taskData['code']) == '') {
                    continue;
                }
                $task =& $atasks_handler->create();
                if (isset($taskData['enabled'])) {
                    $task->setVar('sat_enabled', $taskData['enabled']);
                }
                if (isset($taskData['repeat'])) {
                    $task->setVar('sat_repeat', $taskData['repeat']);
                }
                if (isset($taskData['interval'])) {
                    $task->setVar('sat_interval', $taskData['interval']);
                }
                if (isset($taskData['onfinish'])) {
                    $task->setVar('sat_onfinish', $taskData['onfinish']);
                }
                $task->setVar('sat_name', $taskData['name']);
                $task->setVar('sat_code', sprintf("require ICMS_ROOT_PATH . \"/modules/%s/%s\";", $module->getInfo('dirname'), addslashes($taskData['code'])));
                $task->setVar('sat_type', 'addon/' . $module->getInfo('dirname'));
                $task->setVar('sat_addon_id', (int) $taskID);
                if (!$atasks_handler->insert($task)) {
                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not insert autotask to db. Name: <b>' . $taskData['name'] . '</b></span>';
                } else {
                    $msgs[] = '&nbsp;&nbsp;Updated task from autotasks list. Task Name: <b>' . $taskData['name'] . '</b>';
                }
            }
            unset($atasks, $atasks_handler, $task, $taskData, $criteria, $items, $taskID);
        }
        // execute module specific update script if any
        $update_script = $module->getInfo('onUpdate');
        $ModName = $module->getInfo('modname') != '' ? trim($module->getInfo('modname')) : $dirname;
        if (false != $update_script && trim($update_script) != '') {
            include_once ICMS_ROOT_PATH . '/modules/' . $dirname . '/' . trim($update_script);
            $is_IPF = $module->getInfo('object_items');
            if (!empty($is_IPF)) {
                $icmsDatabaseUpdater = icms_db_legacy_Factory::getDatabaseUpdater();
                $icmsDatabaseUpdater->moduleUpgrade($module, true);
                foreach ($icmsDatabaseUpdater->_messages as $msg) {
                    $msgs[] = $msg;
                }
            }
            if (function_exists('xoops_module_update_' . $ModName)) {
                $func = 'xoops_module_update_' . $ModName;
                if (!$func($module, $prev_version, $prev_dbversion)) {
                    $msgs[] = sprintf(_MD_AM_FAIL_EXEC, '<strong>' . $func . '</strong>');
                } else {
                    $msgs[] = sprintf(_MD_AM_FUNCT_EXEC, '<strong>' . $func . '</strong>');
                }
            } elseif (function_exists('icms_module_update_' . $ModName)) {
                $func = 'icms_module_update_' . $ModName;
                if (!$func($module, $prev_version, $prev_dbversion)) {
                    $msgs[] = sprintf(_MD_AM_FAIL_EXEC, '<strong>' . $func . '</strong>');
                } else {
                    $msgs[] = sprintf(_MD_AM_FUNCT_EXEC, '<strong>' . $func . '</strong>');
                }
            }
        }
        $msgs[] = '</code><p>' . sprintf(_MD_AM_OKUPD, '<b>' . $module->getVar('name') . '</b>') . '</p>';
    }
    $ret = '<code>';
    foreach ($msgs as $msg) {
        $ret .= $msg . '<br />';
    }
    return $ret;
}
Example #22
0
/**
 * Gets module handler
 * For Backward Compatibility.
 *
 * @param	string  $name  The name of the module
 * @param	string	$module_dir		The module directory where to get the module class
 * @return	object  $inst	The reference to the generated object
 * @deprecated Use icms_getmodulehandler instead
 * @todo Remove this function in version 1.4
 */
function &xoops_getmodulehandler($name = null, $module_dir = null, $optional = false)
{
    icms_core_Debug::setDeprecated('icms_getModuleHandler', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
    return icms_getModuleHandler($name, $module_dir, $module_dir, $optional);
}
Example #23
0
 function getCronTabUser()
 {
     static $user = null;
     if ($user === null) {
         $atasks_handler =& icms_getModuleHandler('autotasks', 'system');
         $config =& $atasks_handler->getConfig();
         $user = $config['autotasks_user'];
     }
     if (trim("{$user}") == '') {
         $user = '';
     }
     return $user;
 }
Example #24
0
        $sform = $contentObj->getForm(_AM_CONTENT_CONTENT_CLONE, 'addcontent');
        $sform->assign($icmsAdminTpl);
    } else {
        $contentObj->hideFieldFromForm(array('content_published_date', 'content_updated_date'));
        $contentObj->setVar('content_published_date', date(_DATESTRING));
        if ($content_pid) {
            $contentObj->setVar('content_pid', $content_pid);
        }
        icms::$module->displayAdminMenu(0, _AM_CONTENT_CONTENTS . " > " . _CO_ICMS_CREATINGNEW);
        $sform = $contentObj->getForm(_AM_CONTENT_CONTENT_CREATE, 'addcontent');
        $sform->assign($icmsAdminTpl);
    }
    $icmsAdminTpl->display('db:content_admin_content.html');
}
include_once "admin_header.php";
$content_content_handler = icms_getModuleHandler('content', basename(dirname(dirname(__FILE__))), "content");
/** Use a naming convention that indicates the source of the content of the variable */
$clean_op = '';
/** Create a whitelist of valid values, be sure to use appropriate types for each value
 * Be sure to include a value for no parameter, if you have a default condition
 */
$valid_op = array('mod', 'changedField', 'addcontent', 'del', 'clone', 'view', '');
if (isset($_GET['op'])) {
    $clean_op = htmlentities($_GET['op']);
}
if (isset($_POST['op'])) {
    $clean_op = htmlentities($_POST['op']);
}
/** Again, use a naming convention that indicates the source of the content of the variable */
$clean_content_id = isset($_GET['content_id']) ? (int) $_GET['content_id'] : 0;
$clean_content_id = isset($_POST['content_id']) ? (int) $_POST['content_id'] : $clean_content_id;
Example #25
0
 /**
  * Get names of user variables
  *
  * @return array
  */
 private function getUserVars()
 {
     $profile_handler = icms_getModuleHandler('profile', basename(dirname(dirname(__FILE__))), 'profile');
     return $profile_handler->getUserVars();
 }
Example #26
0
 /**
  * Retreive a single object
  *
  * @param string $itemname
  * @param string $key
  *
  * @return the requestd object or FALSE if they don't exists in the registry
  */
 public function getSingleObject($itemname, $key, $modulename = false)
 {
     if (!$modulename) {
         global $icmsModule;
         if (!is_object($icmsModule)) {
             return false;
         } else {
             $modulename = $icmsModule->getVar("dirname");
         }
     }
     if (isset($this->_registryArray['objects'][$modulename][$itemname][$key])) {
         return $this->_registryArray['objects'][$modulename][$itemname][$key];
     } else {
         $objectHandler = icms_getModuleHandler($itemname, $modulename);
         $object = $objectHandler->get($key);
         if (!$object->isNew()) {
             $this->_registryArray['objects'][$modulename][$itemname][$key] = $object;
             return $object;
         } else {
             return false;
         }
     }
 }
Example #27
0
 /**
  * Gets list of all user ranks in the database
  * @deprecated	Use SystemUserrankHandler->getList
  * @todo		Remove in version 1.4
  *
  * @return  array	 $ret   list of user ranks
  */
 public static function getUserRankList()
 {
     icms_core_Debug::setDeprecated('SystemUserrankHandler->getList', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
     return icms_getModuleHandler("userrank", "system")->getList(icms_buildCriteria(array("rank_special" => 1)));
 }
Example #28
0
    icms_cp_header();
    $userrankObj = $icms_userrank_handler->get($rank_id);
    if (!$clone && !$userrankObj->isNew()) {
        $sform = $userrankObj->getForm(_CO_ICMS_USERRANKS_EDIT, "adduserrank");
        $sform->assign($icmsAdminTpl);
        $icmsAdminTpl->assign("icms_userrank_title", _CO_ICMS_USERRANKS_EDIT_INFO);
        $icmsAdminTpl->display("db:admin/userrank/system_adm_userrank.html");
    } else {
        $userrankObj->setVar("rank_id", 0);
        $sform = $userrankObj->getForm(_CO_ICMS_USERRANKS_CREATE, "adduserrank");
        $sform->assign($icmsAdminTpl);
        $icmsAdminTpl->assign("icms_userrank_title", _CO_ICMS_USERRANKS_CREATE_INFO);
        $icmsAdminTpl->display("db:admin/userrank/system_adm_userrank.html");
    }
}
$icms_userrank_handler = icms_getModuleHandler("userrank", "system");
if (!empty($_POST)) {
    foreach ($_POST as $k => $v) {
        ${$k} = StopXSS($v);
    }
}
if (!empty($_GET)) {
    foreach ($_GET as $k => $v) {
        ${$k} = StopXSS($v);
    }
}
$op = isset($_POST['op']) ? trim(filter_input(INPUT_POST, 'op')) : (isset($_GET['op']) ? trim(filter_input(INPUT_GET, 'op')) : '');
switch ($op) {
    case "mod":
        $rank_id = isset($_GET["rank_id"]) ? (int) $_GET["rank_id"] : 0;
        edituserrank(TRUE, $rank_id);
Example #29
0
 /**
  * get the user's rank
  * @return array array of rank ID and title
  */
 public function rank()
 {
     if (!isset($this->_rank)) {
         $this->_rank = icms_getModuleHandler("userrank", "system")->getRank($this->getVar('rank'), $this->getVar('posts'));
     }
     return $this->_rank;
 }
/**
 * Comment include file
 *
 * File holding functions used by the module to hook with the comment system of ImpressCMS
 *
 * @copyright	(c) 2011 David Janssens
 * @license		http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
 * @since		1.0
 * @author		David Janssens (fiammybe) <*****@*****.**>
 * @package		billboard
 * @version		$Id$
 */
function billboard_com_update($item_id, $total_num)
{
    $billboard_post_handler = icms_getModuleHandler("post", basename(dirname(dirname(__FILE__))), "billboard");
    $billboard_post_handler->updateComments($item_id, $total_num);
}