function smarty_function_xoInboxCount($params, &$smarty) { global $xoopsUser; if (!isset($xoopsUser) || !is_object($xoopsUser)) { return; } $time = time(); if (isset($_SESSION['xoops_inbox_count']) && @$_SESSION['xoops_inbox_count_expire'] > $time) { $count = intval($_SESSION['xoops_inbox_count']); } else { $module_handler = xoops_gethandler('module'); $pm_module = $module_handler->getByDirname('pm'); if ($pm_module && $pm_module->getVar('isactive')) { $pm_handler =& xoops_getModuleHandler('message', 'pm'); } else { $pm_handler =& xoops_gethandler('privmessage'); } $criteria = new CriteriaCompo(new Criteria('read_msg', 0)); $criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid'))); $count = intval($pm_handler->getCount($criteria)); $_SESSION['xoops_inbox_count'] = $count; $_SESSION['xoops_inbox_count_expire'] = $time + 60; } if (!@empty($params['assign'])) { $smarty->assign($params['assign'], $count); } else { echo $count; } }
public function getCategoryList($uid = 0) { $criteria = new CriteriaCompo(); if (!empty($uid)) { $criteria->add(new Criteria("uid", $uid)); } $criteria->setOrder("ASC"); $criteria->setSort("cat_id"); $categories = $this->getAll($criteria); $catarr = array(); if ($this->getCount($criteria)) { unset($criteria); $topic_handler = xoops_getmodulehandler("topics", "press"); $criteria = new CriteriaCompo(new Criteria("cat_id", "(" . implode(",", array_keys($categories)) . ")", "in")); if (!empty($uid)) { $criteria->add(new Criteria("uid", $uid)); } $criteria->setGroupby("cat_id"); $counts = $topic_handler->getCounts($criteria); foreach ($categories as $key => $obj) { $catarr[$key]["cat_name"] = $obj->getVar("cat_name"); $catarr[$key]["cat_id"] = $key; if (!empty($uid)) { $catarr[$key]["uid"] = $uid; } $catarr[$key]["cat_topics"] = isset($counts[$key]) ? $counts[$key] : 0; } return $catarr; } }
function smarty_function_xoInboxCount($params, &$smarty) { $xoops = Xoops::getInstance(); if (!$xoops->isUser()) { return; } $time = time(); if (isset($_SESSION['xoops_inbox_count']) && @$_SESSION['xoops_inbox_count_expire'] > $time) { $count = (int) $_SESSION['xoops_inbox_count']; } else { $pm_handler = $xoops->getHandlerPrivateMessage(); $xoopsPreload = XoopsPreload::getInstance(); $xoopsPreload->triggerEvent('core.class.smarty.xoops_plugins.xoinboxcount', array($pm_handler)); $criteria = new CriteriaCompo(new Criteria('read_msg', 0)); $criteria->add(new Criteria('to_userid', $xoops->user->getVar('uid'))); $count = (int) $pm_handler->getCount($criteria); $_SESSION['xoops_inbox_count'] = $count; $_SESSION['xoops_inbox_count_expire'] = $time + 60; } if (!@empty($params['assign'])) { $smarty->assign($params['assign'], $count); } else { echo $count; } }
function b_categories_list_show($options) { include_once XOOPS_ROOT_PATH . "/modules/smartpartner/include/common.php"; $smartpartner_category_handler =& smartpartner_gethandler('category'); $criteria = new CriteriaCompo(); $criteria->setSort(isset($options[0]) ? $options[0] : 'name'); $criteria->setOrder(isset($options[1]) ? $options[1] : 'ASC'); $catsObj =& $smartpartner_category_handler->getobjects($criteria, true); $catArray = get_content(0, $catsObj, $options[2]); $block = array(); $block['categories'] = $catArray; $block['displaysubs'] = $options[2]; if (isset($_GET['view_category_id'])) { $current_id = $_GET['view_category_id']; $block['current'] = $catsObj[$current_id]->getVar('parentid') == 0 ? $current_id : $catsObj[$current_id]->getVar('parentid'); } elseif (isset($_GET['id'])) { $smartpartner_partner_handler =& smartpartner_gethandler('partner'); $partnerObj = $smartpartner_partner_handler->get($_GET['id']); if (is_object($partnerObj)) { $parent = $partnerObj->getVar('categoryid'); $block['current'] = $catsObj[$parent]->getVar('parentid') == 0 ? $parent : $catsObj[$parent]->getVar('parentid'); } } return $block; }
function _updatePassword(&$controller) { $this->mActionForm->fetch(); $userHandler =& xoops_gethandler('user'); $criteria = new CriteriaCompo(new Criteria('email', $this->mActionForm->get('email'))); $criteria->add(new Criteria('pass', $this->mActionForm->get('code'), '=', '', 'LEFT(%s, 5)')); $lostUserArr =& $userHandler->getObjects($criteria); if (is_array($lostUserArr) && count($lostUserArr) > 0) { $lostUser =& $lostUserArr[0]; } else { return USER_FRAME_VIEW_ERROR; } $newpass = xoops_makepass(); $extraVars['newpass'] = $newpass; $builder = new User_LostPass2MailBuilder(); $director = new User_LostPassMailDirector($builder, $lostUser, $controller->mRoot->mContext->getXoopsConfig(), $extraVars); $director->contruct(); $xoopsMailer =& $builder->getResult(); if (!$xoopsMailer->send()) { // $xoopsMailer->getErrors(); return USER_FRAME_VIEW_ERROR; } $lostUser->set('pass', md5($newpass), true); $userHandler->insert($lostUser, true); return USER_FRAME_VIEW_SUCCESS; }
function xoops_module_update_ckeditor4() { $module_handler = xoops_gethandler('module'); $Module = $module_handler->getByDirname('ckeditor4'); $config_handler = xoops_gethandler('config'); $mid = $Module->mid(); $ModuleConfig = $config_handler->getConfigsByCat(0, $mid); if (substr($ModuleConfig['toolbar_user'], -4) === '""]]') { //fix typo '""]]' to '"]]' for version <= 0.37 $criteria = new CriteriaCompo(new Criteria('conf_modid', $mid)); $criteria->add(new Criteria('conf_catid', 0)); $criteria->add(new Criteria('conf_name', 'toolbar_user')); if ($configs = $config_handler->_cHandler->getObjects($criteria)) { $val = str_replace('""]]', '"]]', $ModuleConfig['toolbar_user']); $configs[0]->setVar('conf_value', $val, true); $config_handler->insertConfig($configs[0]); } } if (preg_match('/^head\\s*$/m', $ModuleConfig['contentsCss'])) { //fix typo 'head' to '<head>' for version <= 0.38 $criteria = new CriteriaCompo(new Criteria('conf_modid', $mid)); $criteria->add(new Criteria('conf_catid', 0)); $criteria->add(new Criteria('conf_name', 'contentsCss')); if ($configs = $config_handler->_cHandler->getObjects($criteria)) { $val = preg_replace('/^head(\\s*)$/m', '<head>$1', $ModuleConfig['contentsCss']); $configs[0]->setVar('conf_value', $val, true); $config_handler->insertConfig($configs[0]); } } return true; }
function getGrantedGroupsForIds($item_ids_array, $gperm_name = false) { static $groups; if ($gperm_name) { if (isset($groups[$gperm_name])) { return $groups[$gperm_name]; } } else { // if !$gperm_name then we will fetch all permissions in the module so we don't need them again return $groups; } $criteria = new CriteriaCompo(); $criteria->add(new Criteria('gperm_modid', $this->mid)); if ($gperm_name) { $criteria->add(new Criteria('gperm_name', $gperm_name)); } $objs = $this->getObjects($criteria); foreach ($objs as $obj) { $groups[$obj->getVar('gperm_name')][$obj->getVar('gperm_itemid')][] = $obj->getVar('gperm_groupid'); } //Return the permission array if ($gperm_name) { return isset($groups[$gperm_name]) ? $groups[$gperm_name] : array(); } else { return isset($groups) ? $groups : array(); } }
function checkLogin(&$xoopsUser) { $root =& XCube_Root::getSingleton(); if ($root->mContext->mUser->isInRole('Site.RegisteredUser')) { return; } $root->mLanguageManager->loadModuleMessageCatalog('user'); $userHandler =& xoops_getmodulehandler('users', 'user'); $criteria = new CriteriaCompo(); if (xoops_getrequest('uname') != "" && strpos(xoops_getrequest('uname'), '@') !== false) { $criteria->add(new Criteria('email', xoops_getrequest('uname'))); } else { $criteria->add(new Criteria('uname', xoops_getrequest('uname'))); // use for both e-mail or uname logiin // $criteria->add(new Criteria('uname','')); // use for only e-mail logiin } $criteria->add(new Criteria('pass', md5(xoops_getrequest('pass')))); $userArr =& $userHandler->getObjects($criteria); if (count($userArr) != 1) { return; } if ($userArr[0]->get('level') == 0) { return; } $handler =& xoops_gethandler('user'); $user =& $handler->get($userArr[0]->get('uid')); $xoopsUser = $user; require_once XOOPS_ROOT_PATH . '/include/session.php'; xoops_session_regenerate(); $_SESSION = array(); $_SESSION['xoopsUserId'] = $xoopsUser->get('uid'); $_SESSION['xoopsUserGroups'] = $xoopsUser->getGroups(); }
function executeViewIndex(&$controller, &$xoopsUser, &$render) { $render->setTemplateName("blockinstall_list.html"); // // Lazy load // foreach (array_keys($this->mObjects) as $key) { $this->mObjects[$key]->loadModule(); } $render->setAttribute("objects", $this->mObjects); $render->setAttribute("pageNavi", $this->mFilter->mNavi); $moduleHandler =& xoops_gethandler('module'); $modules =& $moduleHandler->getObjects(new Criteria('isactive', 1)); $render->setAttribute('modules', $modules); $render->setAttribute('filterForm', $this->mFilter); $render->setAttribute('pageArr', $this->mpageArr); $block_handler =& $this->_getHandler(); $block_total = $block_handler->getCount(); $inactive_block_total = $block_handler->getCount(new Criteria('isactive', 0)); $active_block_total = $block_total - $inactive_block_total; $render->setAttribute('BlockTotal', $block_total); $render->setAttribute('ActiveBlockTotal', $active_block_total); $render->setAttribute('InactiveBlockTotal', $inactive_block_total); $active_installed_criteria = new CriteriaCompo(new Criteria('visible', 1)); $active_installed_criteria->add(new Criteria('isactive', 1)); $active_installed_block_total = $block_handler->getCount($active_installed_criteria); $render->setAttribute('ActiveInstalledBlockTotal', $active_installed_block_total); $render->setAttribute('ActiveUninstalledBlockTotal', $active_block_total - $active_installed_block_total); $inactive_installed_criteria = new CriteriaCompo(new Criteria('visible', 1)); $inactive_installed_criteria->add(new Criteria('isactive', 0)); $inactive_installed_block_total = $block_handler->getCount($inactive_installed_criteria); $render->setAttribute('InactiveInstalledBlockTotal', $inactive_installed_block_total); $render->setAttribute('InactiveUninstalledBlockTotal', $inactive_block_total - $inactive_installed_block_total); }
function getTabTitle() { $title = $this->getVar('tabtitle'); // PM detection and conversion if (preg_match('/{pm_new}/i', $title) || preg_match('/{pm_readed}/i', $title) || preg_match('/{pm_total}/i', $title)) { if (is_object($GLOBALS['xoopsUser'])) { $new_messages = 0; $old_messages = 0; $som = 0; $user_id = 0; $user_id = $GLOBALS['xoopsUser']->getVar('uid'); $pm_handler =& xoops_gethandler('privmessage'); $criteria_new = new CriteriaCompo(new Criteria('read_msg', 0)); $criteria_new->add(new Criteria('to_userid', $GLOBALS['xoopsUser']->getVar('uid'))); $new_messages = $pm_handler->getCount($criteria_new); $criteria_old = new CriteriaCompo(new Criteria('read_msg', 1)); $criteria_old->add(new Criteria('to_userid', $GLOBALS['xoopsUser']->getVar('uid'))); $old_messages = $pm_handler->getCount($criteria_old); $som = $old_messages + $new_messages; if ($new_messages > 0) { $title = preg_replace('/\\{pm_new\\}/', '(<span style="color: rgb(255, 0, 0); font-weight: bold;">' . $new_messages . '</span>)', $title); } if ($old_messages > 0) { $title = preg_replace('/\\{pm_readed\\}/', '(<span style="color: rgb(255, 0, 0); font-weight: bold;">' . $old_messages . '</span>)', $title); } if ($old_messages > 0) { $title = preg_replace('/\\{pm_total\\}/', '(<span style="color: rgb(255, 0, 0); font-weight: bold;">' . $som . '</span>)', $title); } } $title = preg_replace('/\\{pm_new\\}/', '', $title); $title = preg_replace('/\\{pm_readed\\}/', '', $title); $title = preg_replace('/\\{pm_total\\}/', '', $title); } return trim($title); }
/** * @param int $uid * * @return int */ public function userPosts($uid) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('content_status', 0, '!=')); $criteria->add(new Criteria('content_author', (int) $uid)); return \Xoops::getModuleHelper('page')->getContentHandler()->getCount($criteria); }
/** * prepare * * @param void * * @return bool **/ public function prepare() { parent::prepare(); // in case of NEW post if ($this->mObject->isNew()) { if ($this->mRoot->mContext->mUser->isInRole('Site.RegisteredUser')) { $this->mObject->set('uid', $this->mRoot->mContext->mXoopsUser->get('uid')); } $this->mObject->set('post_time', time()); $this->mObject->set('modified_time', time()); $this->mObject->set('uid_hidden', 0); $this->mObject->set('poster_ip', addslashes(@$_SERVER['REMOTE_ADDR'])); $this->mObject->set('modifier_ip', addslashes(@$_SERVER['REMOTE_ADDR'])); // get pid --> is it response post? $pid = (int) $this->mRoot->mContext->mRequest->getRequest('pid'); if (isset($pid) && $pid > 0) { $this->mObject->set('pid', $pid); $topic_id = (int) $this->mRoot->mContext->mRequest->getRequest('topic_id'); $mParentHandler =& $this->_getHandler(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('post_id', $pid)); $mGotObjects =& $mParentHandler->getObjects($criteria, true); $this->mParentObj =& $mGotObjects[0]; // get parent object --> is it really response post? if (is_object($this->mParentObj)) { $this->mObject->set('topic_id', $this->mParentObj->get('topic_id')); $this->mObject->set('subject', "Re: " . ltrim($this->mParentObj->get('subject'), 'Re: ')); $this->mObject->set('depth_in_tree', (int) $this->mParentObj->get('depth_in_tree') + 1); } } //adump($pid,$topic_id); //adump($this->mParentObj); } return true; }
function &getList($avatar_type = null, $avatar_display = null) { $criteria = new CriteriaCompo(); if (isset($avatar_type)) { $avatar_type = ($avatar_type == 'C') ? 'C' : 'S'; $criteria->add(new Criteria('avatar_type', $avatar_type)); } if (isset($avatar_display)) { $criteria->add(new Criteria('avatar_display', intval($avatar_display))); } $avatars =& $this->getObjects($criteria, true); $ret = array(); $ret[] = array( 'id' => 0, 'name' => _NONE, 'file' => 'blank.gif', ); if(is_array($avatars)){ foreach ($avatars as $id => $obj) { $ret[] = array( 'id' => $id, 'name' => $obj->getVar('avatar_name'), 'file' => $obj->getVar('avatar_file'), ); } } return $ret; }
function dispatch() { global $xoopsUser; if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } $uid_from = $xoopsUser->getVar('uid'); $uid_to = $this->getIntRequest('uid', XSNS_REQUEST_GET); $user_handler =& XsnsUserHandler::getInstance(); $user_to =& $user_handler->get($uid_to); if(!is_object($user_to) || !$user_to->isFriend($uid_from)){ redirect_header(XOOPS_URL, 2, _NOPERM); } $criteria = new CriteriaCompo(new Criteria('uid_to', $uid_to)); $criteria->add(new Criteria('uid_from', $uid_from)); $intro_handler =& XsnsIntroductionHandler::getInstance(); $intro_obj_list =& $intro_handler->getObjects($criteria); if(is_array($intro_obj_list) && count($intro_obj_list)>0){ $body = $intro_obj_list[0]->getVar('body', 'e'); } else{ $body = ""; } $this->context->setAttribute('uid_to', $uid_to); $this->context->setAttribute('body', $body); $this->context->setAttribute('user_menu', $user_to->getMypageMenu()); $this->context->setAttribute('user_name', $user_to->getVar('uname')); }
public static function makeKeywordCriteria(CriteriaCompo $cri, $dirname, $keywords, $andor = 'AND') { $handler = Legacy_Utils::getModuleHandler('definition', $dirname); //keywords $keywordArr = self::splitKeywords($keywords); //definition $cri->add(new Criteria('search_flag', 1)); $cri->add(new Criteria('field_type', array(Xcck_FieldType::STRING, Xcck_FieldType::TEXT, Xcck_FieldType::URI), 'IN')); $defObjs = $handler->getObjects($cri); foreach ($defObjs as $obj) { $fieldList['field_name'][] = $obj->get('field_name'); $fieldList['field_type'][] = $obj->get('field_type'); } //page $cri = new CriteriaCompo(); foreach ($defObjs as $def) { foreach ($keywordArr as $keyword) { if (strtoupper($andor) === 'OR') { $cri->add(new Criteria($def->get('field_name'), self::makeKeyword($keyword), 'LIKE'), 'OR'); } else { $cri->add(new Criteria($def->get('field_name'), self::makeKeyword($keyword), 'LIKE')); } } } return $cri; }
function alumniCategoryDisplayChildren($cid = 0, $categoryArray, $prefix = '', $order = '', &$class) { $xoops = Xoops::getInstance(); $moduleDirName = basename(dirname(__DIR__)); $prefix = $prefix . '<img src=\'' . XOOPS_URL . "/modules/{$moduleDirName}/images/arrow.gif'>"; foreach (array_keys($categoryArray) as $i) { $cid = $categoryArray[$i]->getVar('cid'); $pid = $categoryArray[$i]->getVar('pid'); $title = $categoryArray[$i]->getVar('title'); $img = $categoryArray[$i]->getVar('img'); $order = $categoryArray[$i]->getVar('ordre'); echo '<tr class="' . $class . '">'; echo '<td align="left">' . $prefix . ' ' . $categoryArray[$i]->getVar('title') . '</td>'; echo '<td align="center"><img src="' . XOOPS_URL . "/modules/{$moduleDirName}/images/cat/" . $categoryArray[$i]->getVar('img') . '" height="16px" title="img" alt="img"></td>'; echo '<td align="center">' . $categoryArray[$i]->getVar('ordre') . '</td>'; echo "<td align='center' width='10%'>\n\t\t\t\t\t\t<a href='category.php?op=edit_category&cid=" . $categoryArray[$i]->getVar('cid') . "'><img src='../images/edit.gif' alt='" . XoopsLocale::A_EDIT . "' title='" . XoopsLocale::A_EDIT . "'></a>\n\t\t\t\t\t\t<a href='category.php?op=delete_category&cid=" . $categoryArray[$i]->getVar('cid') . "'><img src='../images/dele.gif' alt='" . XoopsLocale::A_DELETE . "' title='" . XoopsLocale::A_DELETE . "'></a></td></tr>"; $class = $class == "even" ? "odd" : "even"; $categoriesHandler = $xoops->getModuleHandler('category', 'alumni'); $criteria2 = new CriteriaCompo(); $criteria2->add(new Criteria('pid', $categoryArray[$i]->getVar('cid'))); $criteria2->setSort('title'); $criteria2->setOrder('ASC'); $cat_pid = $categoriesHandler->getAll($criteria2); $num_pid = $categoriesHandler->getCount(); if ($num_pid != 0) { alumniCategoryDisplayChildren($cid, $cat_pid, $prefix, $order, $class); } } }
/** * @param $params * @param $smarty */ function smarty_function_xoInboxCount($params, &$smarty) { global $xoopsUser; if (!isset($xoopsUser) || !is_object($xoopsUser)) { return; } $time = time(); if (isset($_SESSION['xoops_inbox_count']) && @$_SESSION['xoops_inbox_count_expire'] > $time) { $count = intval($_SESSION['xoops_inbox_count']); } else { $pm_handler =& xoops_gethandler('privmessage'); $xoopsPreload =& XoopsPreload::getInstance(); $xoopsPreload->triggerEvent('core.class.smarty.xoops_plugins.xoinboxcount', array($pm_handler)); $criteria = new CriteriaCompo(new Criteria('read_msg', 0)); $criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid'))); $count = intval($pm_handler->getCount($criteria)); $_SESSION['xoops_inbox_count'] = $count; $_SESSION['xoops_inbox_count_expire'] = $time + 60; } if (!@empty($params['assign'])) { $smarty->assign($params['assign'], $count); } else { echo $count; } }
function xoops_module_update_smartsection($module) { // Load SmartDbUpdater from the SmartObject Framework if present $smartdbupdater = XOOPS_ROOT_PATH . "/modules/smartsection/class/smartdbupdater.php"; include_once $smartdbupdater; $dbupdater = new SmartobjectDbupdater(); ob_start(); echo "<code>" . _SDU_UPDATE_UPDATING_DATABASE . "<br />"; // Adding partial_view field $table = new SmartDbTable('smartsection_items'); if (!$table->fieldExists('partial_view')) { $table->addNewField('partial_view', "varchar(255) NOT NULL default ''"); } else { $table->addAlteredField('partial_view', "varchar(255) NOT NULL default ''"); } if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } unset($table); /** * Check for items with categoryid=0 */ @($smartsection_item_handler = xoops_getmodulehandler('item', 'smartsection')); @($smartsection_category_handler = xoops_getmodulehandler('category', 'smartsection')); if ($smartsection_item_handler) { //find a valid categoryid $categoriesObj = $smartsection_category_handler->getCategories(1, 0, 0, 'weight', 'ASC', false); if (count($categoriesObj) > 0) { $categoryid = $categoriesObj[0]->getVar('categoryid'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('categoryid', 0)); $smartsection_item_handler->updateAll('categoryid', $categoryid, $criteria); echo " Cleaning up items for with categoryid=0<br />"; } } // Adding item_tag field in smartsection_items $table = new SmartDbTable('smartsection_items'); if (!$table->fieldExists('item_tag')) { $table->addNewField('item_tag', "TEXT NOT NULL"); } if ($table->fieldExists('tags')) { $table->addDropedField('tags'); } if (!$dbupdater->updateTable($table)) { /** * @todo trap the errors */ } unset($table); echo "</code>"; $feedback = ob_get_clean(); if (method_exists($module, "setMessage")) { $module->setMessage($feedback); } else { echo $feedback; } return true; }
function &getModule() { global $xoopsUser; $ret = NULL; if(empty($this->module_dirname) || empty($this->user_blog_url)){ return $ret; } $criteria = new CriteriaCompo(new Criteria('hassearch', 1)); $criteria->add(new Criteria('isactive', 1)); $criteria->add(new Criteria('dirname', $this->module_dirname)); $module_handler =& xoops_gethandler('module'); $blog_module_list =& $module_handler->getList($criteria); if(count($blog_module_list) != 1){ return $ret; } $blog_module =& $module_handler->getByDirName($this->module_dirname); if(!is_object($blog_module) || strtolower(get_class($blog_module))!='xoopsmodule'){ return $ret; } $gperm_handler =& xoops_gethandler('groupperm'); $groups = is_object($xoopsUser)? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; if($gperm_handler->checkRight('module_read', $blog_module->getVar('mid'), $groups)) { $ret =& $blog_module; } return $ret; }
function links_block_edit($options) { include_once XOOPS_ROOT_PATH . "/modules/links/include/xoopsformloader.php"; $form = new XoopsBlockForm("", "", ""); $categories = new XoopsFormSelect(_MB_LINKS_SHOWCAT, 'options[0]', $options[0]); $categories->addOption(0, _MB_LINKS_ALL); $cat_handler = xoops_getmodulehandler('category', 'links'); $criteria = new CriteriaCompo(); $criteria->setSort('cat_order'); $criteria->setOrder('ASC'); $category = $cat_handler->getList($criteria); foreach ($cat_handler->getList($criteria) as $k => $v) { $categories->addOption($k, $v); } $form->addElement($categories, true); $sort = new XoopsFormSelect(_MB_LINKS_SORTWAY, 'options[1]', $options[1]); $sort->addOption('published', _MB_LINKS_PUBLISHTIME); $sort->addOption('datetime', _MB_LINKS_UPDATETIME); $sort->addOption('link_order', _MB_LINKS_DEFAULT); $form->addElement($sort, true); $form->addElement(new XoopsFormText(_MB_LINKS_SHOWHOWLIK, "options[2]", 5, 2, $options[2]), true); $form->addElement(new XoopsFormText(_MB_LINKS_LIKTITLEMAX, "options[3]", 5, 2, $options[3]), true); $form->addElement(new XoopsFormRadioYN(_MB_LINKS_SHOWCATTITLE, 'options[4]', $options[4]), true); $display = new XoopsFormSelect(_MB_LINKS_BYSHOW, 'options[5]', $options[5]); $display->addOption('1', _MB_LINKS_LOGOHOR); $display->addOption('2', _MB_LINKS_LOGOVER); $display->addOption('3', _MB_LINKS_TITLEHOR); $display->addOption('4', _MB_LINKS_TITLEVER); $form->addElement($display, true); return $form->render(); }
/** * Get a reference to the only instance of authentication class * * if the class has not been instantiated yet, this will also take * care of that * * @static * @return object Reference to the only instance of authentication class */ function &getAuthConnection() { static $auth_instance; if (!isset($auth_instance)) { $config_handler =& xoops_gethandler('config'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('conf_name', 'auth_method')); $config =& $config_handler->getConfigs($criteria); require_once XOOPS_ROOT_PATH . '/class/auth/auth.php'; if (!$config) { // If there is a config error, we use xoops $xoops_auth_method = 'xoops'; } else { $xoops_auth_method = $config[0]->getVar('conf_value'); } $file = XOOPS_ROOT_PATH . '/class/auth/auth_' . $xoops_auth_method . '.php'; require_once $file; $class = 'XoopsAuth' . ucfirst($xoops_auth_method); switch ($xoops_auth_method) { case 'xoops': $dao =& $GLOBALS['xoopsDB']; break; case 'ldap': $dao = null; break; } $auth_instance = new $class($dao); } return $auth_instance; }
function get_system_main_menu_show() { global $xoopsUser, $xoopsModule; $block = array(); $block['lang_home'] = _MB_SYSTEM_HOME; $block['lang_close'] = _CLOSE; $module_handler =& xoops_gethandler('module'); $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); $criteria->add(new Criteria('isactive', 1)); $criteria->add(new Criteria('weight', 0, '>')); $modules = $module_handler->getObjects($criteria, true); $moduleperm_handler =& xoops_gethandler('groupperm'); $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; $read_allowed = $moduleperm_handler->getItemIds('module_read', $groups); foreach (array_keys($modules) as $i) { if (in_array($i, $read_allowed)) { $block['modules'][$i]['name'] = $modules[$i]->getVar('name'); $block['modules'][$i]['directory'] = $modules[$i]->getVar('dirname'); $sublinks = $modules[$i]->subLink(); if (count($sublinks) > 0) { foreach ($sublinks as $sublink) { $block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => XOOPS_URL . '/modules/' . $modules[$i]->getVar('dirname') . '/' . $sublink['url']); } } else { $block['modules'][$i]['sublinks'] = array(); } } } return $block; }
function getGrantedGroupsForIds($item_ids_array, $gperm_name = false) { static $groups; static $smartsection_all_permissions_fetched; if ($gperm_name) { if (isset($groups[$gperm_name])) { return $groups[$gperm_name]; } } else { // if !$gperm_name then we will fetch all permissions in the module so we don't need them again if ($smartsection_all_permissions_fetched) { return $groups; } else { $smartsection_all_permissions_fetched = true; } } $smartModule =& smartsection_getModuleInfo(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('gperm_modid', $smartModule->getVar('mid'))); if ($gperm_name) { $criteria->add(new Criteria('gperm_name', $gperm_name)); } //Get group permissions handler $gperm_handler =& xoops_gethandler('groupperm'); $permissionsObj = $gperm_handler->getObjects($criteria); foreach ($permissionsObj as $permissionObj) { $groups[$permissionObj->getVar('gperm_name')][$permissionObj->getVar('gperm_itemid')][] = $permissionObj->getVar('gperm_groupid'); } //Return the permission array if ($gperm_name) { return isset($groups[$gperm_name]) ? $groups[$gperm_name] : array(); } else { return isset($groups) ? $groups : array(); } }
function update_block_permissions($old_gid, $new_gid) { // get handlers $gperm_handler =& xoops_gethandler('groupperm'); $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname('xoonips'); $mid = $module->getVar('mid'); $block_objs =& XoopsBlock::getByModule($mid); foreach ($block_objs as $block_obj) { // find moderator menu block if ($block_obj->getVar('show_func') == 'b_xoonips_moderator_show') { $bid = $block_obj->getVar('bid'); // if old_gid don't have module admin right, // delete the right to access from old_gid. if (!$gperm_handler->checkRight('module_admin', $mid, $old_gid)) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('gperm_groupid', $old_gid)); $criteria->add(new Criteria('gperm_itemid', $bid)); $criteria->add(new Criteria('gperm_name', 'block_read')); $gperm_handler->deleteAll($criteria); } // if there is no right to access moderator block in new_gid, // the right gives new_gid. if (!$gperm_handler->checkRight('block_read', $bid, $new_gid)) { $gperm_handler->addRight('block_read', $bid, $new_gid); } break; } } }
/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * For an item with massive members, such as "Registered Users", "$value" should be used to store selected temporary users only instead of all members of that item * @param bool $include_anon Include user "anonymous"? * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ function __construct($caption, $name, $include_anon = false, $value = null, $size = 1, $multiple = false) { $limit = 200; $select_element = new Xmf_Form_Element_Select("", $name, $value, $size, $multiple); if ($include_anon) { $select_element->addOption(0, $GLOBALS["xoopsConfig"]['anonymous']); } $member_handler =& xoops_gethandler('member'); $user_count = $member_handler->getUserCount(); $value = is_array($value) ? $value : (empty($value) ? array() : array($value)); if ($user_count > $limit && count($value) > 0) { $criteria = new CriteriaCompo(new Criteria("uid", "(" . implode(",", $value) . ")", "IN")); } else { $criteria = new CriteriaCompo(); $criteria->setLimit($limit); } $criteria->setSort('uname'); $criteria->setOrder('ASC'); $users = $member_handler->getUserList($criteria); $select_element->addOptionArray($users); if ($user_count <= $limit) { parent::__construct($caption, "", $name); $this->addElement($select_element); return; } xoops_loadLanguage("findusers"); $js_addusers = "<script type=\"text/javascript\">\r\n function addusers(opts){\r\n var num = opts.substring(0, opts.indexOf(\":\"));\r\n opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n var sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");\r\n var arr = new Array(num);\r\n for (var n=0; n < num; n++) {\r\n var nm = opts.substring(0, opts.indexOf(\":\"));\r\n opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n var val = opts.substring(0, opts.indexOf(\":\"));\r\n opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\r\n var txt = opts.substring(0, nm - val.length);\r\n opts = opts.substring(nm - val.length, opts.length);\r\n var added = false;\r\n for (var k = 0; k < sel.options.length; k++) {\r\n if(sel.options[k].value == val){\r\n added = true;\r\n break;\r\n }\r\n }\r\n if (added == false) {\r\n sel.options[k] = new Option(txt, val);\r\n sel.options[k].selected = true;\r\n }\r\n }\r\n return true;\r\n }\r\n </script>"; $token = $GLOBALS['xoopsSecurity']->createToken(); $action_tray = new Xmf_Form_Element_Tray("", " | "); $action_tray->addElement(new Xmf_Form_Element_Label('', "<a href='#' onclick='var sel = xoopsGetElementById(\"" . $name . ($multiple ? "[]" : "") . "\");for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) {sel.options[i] = null;}}; return false;'>" . _MA_USER_REMOVE . "</a>")); $action_tray->addElement(new Xmf_Form_Element_Label('', "<a href='#' onclick='openWithSelfMain(\"" . XOOPS_URL . "/include/findusers.php?target={$name}&multiple={$multiple}&token={$token}\", \"userselect\", 800, 600, null); return false;' >" . _MA_USER_MORE . "</a>" . $js_addusers)); parent::__construct($caption, "<br /><br />", $name); $this->addElement($select_element); $this->addElement($action_tray); }
function setContent() { global $jieqiTpl; global $jieqiConfigs; if (empty($_SESSION['jieqiUserId'])) { return false; } else { jieqi_getconfigs('article', 'configs'); $article_static_url = empty($jieqiConfigs['article']['staticurl']) ? $GLOBALS['jieqiModules']['article']['url'] : $jieqiConfigs['article']['staticurl']; $article_dynamic_url = empty($jieqiConfigs['article']['dynamicurl']) ? $GLOBALS['jieqiModules']['article']['url'] : $jieqiConfigs['article']['dynamicurl']; $jieqiTpl->assign('article_static_url', $article_static_url); $jieqiTpl->assign('article_dynamic_url', $article_dynamic_url); include_once $GLOBALS['jieqiModules']['article']['path'] . '/class/article.php'; $article_handler =& JieqiArticleHandler::getInstance('JieqiArticleHandler'); $criteria = new CriteriaCompo(new Criteria('posterid', $_SESSION['jieqiUserId'], '=')); $criteria->add(new Criteria('authorid', $_SESSION['jieqiUserId'], '!='), 'AND'); $article_handler->queryObjects($criteria); $articlerows = array(); $i = 0; while ($v = $article_handler->getObject()) { $articlerows[$i]['articleid'] = $v->getVar('articleid'); $articlerows[$i]['articlename'] = $v->getVar('articlename'); $i++; } $jieqiTpl->assign_by_ref('articlerows', $articlerows); } }
/** * XXX * * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @since 2.6.0 * @author Mage Grégory (AKA Mage) * @version $Id: $ */ function xoops_module_update_search(XoopsModule &$module) { $xoops = Xoops::getInstance(); // Copy old configs in new configs and delete old configs $config_handler = $xoops->getHandlerConfig(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('conf_modid', 0)); $criteria->add(new Criteria('conf_catid', 5)); $configs = $config_handler->getConfigs($criteria); $confcount = count($configs); if ($confcount > 0) { for ($i = 0; $i < $confcount; ++$i) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('conf_modid', $module->getVar('mid'))); $criteria->add(new Criteria('conf_name', $configs[$i]->getvar('conf_name'))); $new_configs = $config_handler->getConfigs($criteria); $new_confcount = count($new_configs); if ($new_confcount > 0) { for ($j = 0; $j < $new_confcount; ++$j) { $obj = $config_handler->getConfig($new_configs[$j]->getvar('conf_id')); } $obj->setVar("conf_value", $configs[$i]->getvar('conf_value')); $config_handler->insertConfig($obj); $config_handler->deleteConfig($configs[$i]); } } } return true; }
/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * For an item with massive members, such as "Registered Users", "$value" should be used to store selected temporary users only instead of all members of that item * @param bool $include_anon Include user "anonymous"? * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ function XoopsFormSelectUser($caption, $name, $value = array(), $include_anon = false, $size = 1, $multiple = false) { $this->XoopsFormElementTray($caption, "<br /><br />", $name); $select_form = new XoopsFormSelect("", $name, $value, $size, $multiple); if ($include_anon) { $select_form->addOption(0, $GLOBALS["xoopsConfig"]['anonymous']); } $member_handler =& xoops_gethandler('member'); $criteria = new CriteriaCompo(); if (!is_array($value)) { $value = array($value); } if (is_array($value) && count($value) > 0) { $id_in = "(" . implode(",", $value) . ")"; $criteria->add(new Criteria("uid", $id_in, "IN")); $criteria->setSort('name'); $criteria->setOrder('ASC'); $users = $member_handler->getUserList($criteria); $select_form->addOptionArray($member_handler->getUserList($criteria)); } $action_tray = new XoopsFormElementTray("", " | "); $action_tray->addElement(new XoopsFormLabel('', "<a href='###' onclick='return openWithSelfMain(\"" . XOOPS_URL . "/modules/system/include/userselect.php?action=1&target=" . $name . "&multiple=" . $multiple . "\", \"userselect\", 800, 500, null);' >" . _LIST . "</a>")); $action_tray->addElement(new XoopsFormLabel('', "<a href='###' onclick='return openWithSelfMain(\"" . XOOPS_URL . "/modules/system/include/userselect.php?action=0&target=" . $name . "&multiple=" . $multiple . "\", \"userselect\", 800, 500, null);' >" . _SEARCH . "</a>")); $action_tray->addElement(new XoopsFormLabel('', "<a href='###' onclick='var sel = xoopsGetElementById(\"" . $name . "\");for (var i = sel.options.length-1; i >= 0; i--) {if (sel.options[i].selected) {sel.options[i] = null;}}'>" . _REMOVE . "</a>" . "<script type=\"text/javascript\">\n\t\t function addusers(opts){\n\t\t\t var num = opts.substring(0, opts.indexOf(\":\"));\n\t\t\t opts = opts.substring(opts.indexOf(\":\")+1, opts.length);\n \t\tvar sel = xoopsGetElementById(\"" . $name . "\");\n\t\t\t var arr = new Array(num);\n\t\t\t for(var n=0; n<num; n++){\n\t\t\t \tvar nm = opts.substring(0, opts.indexOf(\":\"));\n\t\t\t \topts = opts.substring(opts.indexOf(\":\")+1, opts.length);\n\t\t\t \tvar val = opts.substring(0, opts.indexOf(\":\"));\n\t\t\t \topts = opts.substring(opts.indexOf(\":\")+1, opts.length);\n\t\t\t \tvar txt = opts.substring(0, nm - val.length);\n\t\t\t \topts = opts.substring(nm - val.length, opts.length);\n\t\t\t\t\tvar added = false;\n\t\t\t\t\tfor (var k = 0; k < sel.options.length; k++) {\n\t\t\t\t\t\tif(sel.options[k].value == val){\n\t\t\t\t\t\t\tadded = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(added==false){\n\t\t\t\t\t\tappendSelectOption(\"" . $name . "\",txt, val);\n\t \t\t}\n\t\t\t }\n\t\t\t\treturn true;\n\t\t }\n\t\t\t</script>")); $this->addElement($select_form); $this->addElement($action_tray); }
/** * Constructor * * @param string $caption * @param string $name * @param mixed $value Pre-selected value (or array of them). * For an item with massive members, such as "Registered Users", "$value" should be used to store selected temporary users only instead of all members of that item * @param bool $include_anon Include user "anonymous"? * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ function XoopsFormSelectUser($caption, $name, $include_anon = false, $value = null, $size = 1, $multiple = false) { $limit = 200; $select_element = new XoopsFormSelect('', $name, $value, $size, $multiple); if ($include_anon) { $select_element->addOption(0, $GLOBALS['xoopsConfig']['anonymous']); } $member_handler =& xoops_gethandler('member'); $user_count = $member_handler->getUserCount(); $value = is_array($value) ? $value : (empty($value) ? array() : array($value)); if ($user_count > $limit && count($value) > 0) { $criteria = new CriteriaCompo(new Criteria('uid', '(' . implode(',', $value) . ')', 'IN')); } else { $criteria = new CriteriaCompo(); $criteria->setLimit($limit); } $criteria->setSort('uname'); $criteria->setOrder('ASC'); $users = $member_handler->getUserList($criteria); $select_element->addOptionArray($users); if ($user_count <= $limit) { $this->XoopsFormElementTray($caption, "", $name); $this->addElement($select_element); return; } xoops_loadLanguage('findusers'); $js_addusers = "<script type='text/javascript'>\r\n function addusers(opts){\r\n var num = opts.substring(0, opts.indexOf(':'));\r\n opts = opts.substring(opts.indexOf(':')+1, opts.length);\r\n var sel = xoopsGetElementById('" . $name . "');\r\n var arr = new Array(num);\r\n for (var n=0; n < num; n++) {\r\n var nm = opts.substring(0, opts.indexOf(':'));\r\n opts = opts.substring(opts.indexOf(':')+1, opts.length);\r\n var val = opts.substring(0, opts.indexOf(':'));\r\n opts = opts.substring(opts.indexOf(':')+1, opts.length);\r\n var txt = opts.substring(0, nm - val.length);\r\n opts = opts.substring(nm - val.length, opts.length);\r\n var added = false;\r\n for (var k = 0; k < sel.options.length; k++) {\r\n if(sel.options[k].value == val){\r\n added = true;\r\n break;\r\n }\r\n }\r\n if (added == false) {\r\n sel.options[k] = new Option(txt, val);\r\n sel.options[k].selected = true;\r\n }\r\n }\r\n return true;\r\n }\r\n </script>"; $token = $GLOBALS['xoopsSecurity']->createToken(); $action_tray = new XoopsFormElementTray("", " | "); $action_tray->addElement(new XoopsFormLabel('', '<a href="#" onclick="var sel = xoopsGetElementById(\'' . $name . '\');for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) {sel.options[i] = null;}}; return false;">' . _MA_USER_REMOVE . "</a>")); $action_tray->addElement(new XoopsFormLabel('', '<a href="#" onclick="openWithSelfMain(\'' . XOOPS_URL . '/include/findusers.php?target=' . $name . '&multiple=' . $multiple . '&token=' . $token . '\', \'userselect\', 800, 600, null); return false;" >' . _MA_USER_MORE . "</a>" . $js_addusers)); $this->XoopsFormElementTray($caption, '<br /><br />', $name); $this->addElement($select_element); $this->addElement($action_tray); }
/** * @param int $uid * * @return int */ public function userPosts($uid) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('content_status', 0, '!=')); $criteria->add(new Criteria('content_author', (int) $uid)); return Page::getInstance()->getContentHandler()->getCount($criteria); }