public function list_users($template = "default", $per_page = 10) { list($template_block, $template_block_item) = $this->loadTemplates("users/list_users/" . $template, "block", "block_item"); $block_arr = array(); $curr_page = (int) getRequest('p'); $type_id = umiObjectTypesCollection::getInstance()->getBaseType("users", "user"); $type = umiObjectTypesCollection::getInstance()->getType($type_id); $is_active_field_id = $type->getFieldId('is_activated'); $sel = new umiSelection(); $sel->addLimit($per_page, $curr_page); $sel->addObjectType($type_id); $sel->addPropertyFilterEqual($is_active_field_id, true); $this->autoDetectOrders($sel, $type_id); $this->autoDetectFilters($sel, $type_id); $result = umiSelectionsParser::runSelection($sel); $total = umiSelectionsParser::runSelectionCounts($sel); $items = array(); foreach ($result as $user_id) { $item_arr = array(); $item_arr['void:user_id'] = $user_id; $item_arr['attribute:id'] = $user_id; $item_arr['xlink:href'] = "uobject://" . $user_id; $items[] = def_module::parseTemplate($template_block_item, $item_arr, false, $user_id); } $block_arr['subnodes:items'] = $items; $block_arr['per_page'] = $per_page; $block_arr['total'] = $total; return def_module::parseTemplate($template_block, $block_arr); }
/** * Gets news with specified type. Uses paging. * * @param int $type Id of type (rubric) * @param int $limit Limit for output * @param int $page Current page for calculate offset * @return array */ public function getList($type, $limit, $page = 1) { $config = parse_ini_file("./config/config.ini", true); $page -= 1; $hierarchyTypeId = umiHierarchyTypesCollection::getInstance()->getTypeByName("news", "item")->getId(); $objectTypeId = umiObjectTypesCollection::getInstance()->getBaseType("news", "item"); $objectType = umiObjectTypesCollection::getInstance()->getType($objectTypeId); $publishTimeFieldId = $objectType->getFieldId('publish_time'); $publishToAppFieldId = $objectType->getFieldId('publish_to_app'); $sel = new umiSelection(); $sel->addElementType($hierarchyTypeId); $sel->addHierarchyFilter($type, 0, true); if ($config["umi"]["ignore-publish-flag"] != 1) { $sel->addPropertyFilterEqual($publishToAppFieldId, true); } $sel->setOrderByProperty($publishTimeFieldId, false); $sel->addLimit($limit, $page); $result = umiSelectionsParser::runSelection($sel); $items = array(); $size = sizeof($result); for ($i = 0; $i < $size; $i++) { $elementId = $result[$i]; $element = umiHierarchy::getInstance()->getElement($elementId); if (!$element) { continue; } $items[] = array("id" => $elementId, "header" => $element->getValue("h1"), "date" => $element->getValue("publish_time")->getFormattedDate("d.m.Y"), "image" => "http://" . $_SERVER['HTTP_HOST'] . $element->getValue("anons_pic"), "original_link" => "http://" . $_SERVER['HTTP_HOST'] . umiHierarchy::getInstance()->getPathById($elementId)); } return $items; }
public function shared_files() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } $per_page = 20; $curr_page = getRequest('p'); $hierarchyTypes = umiHierarchyTypesCollection::getInstance(); $hierarchy_type_id = $hierarchyTypes->getTypeByName("filemanager", "shared_file")->getId(); $sel = new umiSelection(); $sel->addLimit($per_page, $curr_page); $sel->addElementType($hierarchy_type_id); $this->autoDetectAllFilters($sel); $sel->addPermissions(); $result = umiSelectionsParser::runSelection($sel); $total = umiSelectionsParser::runSelectionCounts($sel); $this->setDataType("list"); $this->setActionType("view"); $this->setDataRange($per_page, $curr_page * $per_page); $data = $this->prepareData($result, "pages"); $this->setData($data, $total); return $this->doData(); }
public function subscribers_list() { // input $iDispId = $_REQUEST['param0']; // set tab $this->sheets_set_active("subscribers_list"); //input: $this->load_forms(); $iCurrPage = (int) $_REQUEST['p']; $params = array(); // gen banners list $params['rows'] = ""; // $oSbsSelection = new umiSelection(); $oSbsSelection->setObjectTypeFilter(); $oSbsSelection->setLimitFilter(); $oSbsSelection->addLimit($this->per_page, $iCurrPage); $iHierarchyTypeId = umiHierarchyTypesCollection::getInstance()->getTypeByName("dispatches", "subscriber")->getId(); $iSbsTypeId = umiObjectTypesCollection::getInstance()->getTypeByHierarchyTypeId($iHierarchyTypeId); $oSbsType = umiObjectTypesCollection::getInstance()->getType($iSbsTypeId); $oSbsSelection->addObjectType($iSbsTypeId); // add curr dispatch filter if ($iDispId) { $oDispObj = umiObjectsCollection::getInstance()->getObject($iDispId); if ($oDispObj instanceof umiObject) { $oSbsSelection->setPropertyFilter(); $oSbsSelection->addPropertyFilterEqual($oSbsType->getFieldId('subscriber_dispatches'), $iDispId); } } $arrSelResults = umiSelectionsParser::runSelection($oSbsSelection); $iCountResults = umiSelectionsParser::runSelectionCounts($oSbsSelection); $iSbsNum = $this->per_page * $iCurrPage; for ($iI = 0; $iI < count($arrSelResults); $iI++) { $params['rows'] .= self::renderSubscriber($arrSelResults[$iI], ++$iSbsNum); } $params['pages'] = $this->generateNumPage($iCountResults, $this->per_page, $iCurrPage); return $this->parse_form("subscribers_list", $params); }
public function getMessageLink($element_id = false) { $element_id = $this->analyzeRequiredPath($element_id); $per_page = $this->per_page; $curr_page = (int) getRequest('p'); $element = umiHierarchy::getInstance()->getElement($element_id, true); if (!$element) { throw new publicException(getLabel('error-page-does-not-exist', null, '')); } $parent_id = $element->getParentId(); $parent_element = umiHierarchy::getInstance()->getElement($parent_id); if (!$parent_element) { throw new publicException(getLabel('error-parent-does-not-exist', null, '')); } if ($element->getValue("publish_time")) { $publish_time = $element->getValue("publish_time")->getFormattedDate("U"); } $sel = new umiSelection(); $sel->setLimitFilter(); $sel->addLimit($per_page, $curr_page); $sel->setElementTypeFilter(); $topic_hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("forum", "message")->getId(); $sel->addElementType($topic_hierarchy_type_id); $sel->setHierarchyFilter(); $sel->addHierarchyFilter($parent_id); $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("forum", "message"); $object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id); $publish_time_field_id = $object_type->getFieldId('publish_time'); $sel->setOrderFilter(); $sel->setOrderByProperty($publish_time_field_id, true); $sel->setPropertyFilter(); $sel->addPropertyFilterLess($publish_time_field_id, $publish_time); $sel->setPermissionsFilter(); $sel->addPermissions(); $total = umiSelectionsParser::runSelectionCounts($sel); $p = floor(($total - 1) / $this->per_page); if ($p < 0) { $p = 0; } return umiHierarchy::getInstance()->getPathById($parent_id) . "?p={$p}#" . $element_id; }
public function fill_release($dispatch_id = false, $ignore_redirect = false) { $iDispId = $dispatch_id ? $dispatch_id : getRequest('param0'); $oDispatch = umiObjectsCollection::getInstance()->getObject($iDispId); if ($oDispatch instanceof umiObject) { $iReleaseId = $this->getNewReleaseInstanceId($iDispId); $iNewsRelation = $oDispatch->getValue("news_relation"); $arrNewsLents = umiHierarchy::getInstance()->getObjectInstances($iNewsRelation, false, true); // get all releases $iHierarchyTypeId = umiHierarchyTypesCollection::getInstance()->getTypeByName("dispatches", "release")->getId(); $iReleaseTypeId = umiObjectTypesCollection::getInstance()->getTypeByHierarchyTypeId($iHierarchyTypeId); $oReleaseType = umiObjectTypesCollection::getInstance()->getType($iReleaseTypeId); $sel = new umiSelection(); $sel->setObjectTypeFilter(); $sel->addObjectType($iReleaseTypeId); $sel->setPropertyFilter(); $sel->addPropertyFilterEqual($oReleaseType->getFieldId('disp_reference'), $iDispId); $arrReleases = umiSelectionsParser::runSelection($sel); if (count($arrNewsLents)) { $iElementId = (int) $arrNewsLents[0]; $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("news", "item")->getId(); $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("news", "item"); $object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id); $publish_time_field_id = $object_type->getFieldId('publish_time'); $sel = new umiSelection(); $sel->setElementTypeFilter(); $sel->addElementType($hierarchy_type_id); $sel->setOrderFilter(); $sel->setOrderByProperty($publish_time_field_id, false); $sel->setHierarchyFilter(); $sel->addHierarchyFilter($iElementId, 0, true); $sel->setLimitFilter(); $sel->addLimit(50); $sel->setIsLangIgnored(true); /* $sel->setPropertyFilter(); $sel->addPropertyFilterBetween($publish_time_field_id, $date1, $date2); */ $result = umiSelectionsParser::runSelection($sel); for ($iI = 0; $iI < count($result); $iI++) { $iNextNewId = $result[$iI]; $oNextNew = umiHierarchy::getInstance()->getElement($iNextNewId); if ($oNextNew instanceof umiHierarchyElement) { $sName = $oNextNew->getName(); $sHeader = $oNextNew->getValue('h1'); $sShortBody = $oNextNew->getValue('anons'); $sBody = $oNextNew->getValue('content'); $oPubTime = $oNextNew->getValue('publish_time'); if (!strlen($sBody)) { $sBody = $sShortBody; } // add message $iHierarchyTypeId = umiHierarchyTypesCollection::getInstance()->getTypeByName("dispatches", "message")->getId(); $iMsgTypeId = umiObjectTypesCollection::getInstance()->getTypeByHierarchyTypeId($iHierarchyTypeId); $oMsgType = umiObjectTypesCollection::getInstance()->getType($iMsgTypeId); // check if new exists $oSel = new umiSelection(); $oSel->setObjectTypeFilter(); $oSel->addObjectType($iMsgTypeId); $oSel->setPropertyFilter(); $oSel->addPropertyFilterEqual($oMsgType->getFieldId('new_relation'), $iNextNewId); $oSel->setPropertyFilter(); $oSel->addPropertyFilterEqual($oMsgType->getFieldId('release_reference'), $arrReleases); $oSel->setLimitFilter(); $oSel->addLimit(1); $iCount = umiSelectionsParser::runSelectionCounts($oSel); if ($iCount > 0) { continue; } //add new message $iMsgObjId = umiObjectsCollection::getInstance()->addObject($sName, $iMsgTypeId); // try get object $oMsgObj = umiObjectsCollection::getInstance()->getObject($iMsgObjId); if ($oMsgObj instanceof umiObject) { $oMsgObj->setValue('release_reference', $iReleaseId); $oMsgObj->setValue('header', $sHeader); $oMsgObj->setValue('body', $sBody); $oMsgObj->setValue('short_body', $sShortBody); $oMsgObj->setValue('new_relation', array($iNextNewId)); if ($oPubTime instanceof umiDate) { $oMsgObj->setValue('msg_date', $oPubTime); } $oMsgObj->commit(); } } } } } // WTF? IE7 does not send the HTTP_REFERER header, so we should set the redirect string manually if (!$ignore_redirect) { $this->chooseRedirect('/admin/dispatches/edit/' . $iDispId . '/'); } }
public function tryPreAuth() { $v870fd5468174f846789cb0d56d95bed7 = ""; $v61b14997da4f52f41ee7b0d90f09e670 = ""; $ve218c54eefdbe103350435489a6595cb = ""; $v2b2dccfdbf6e767de8512d66da6d18ca = 'u-login'; $vad1ffbcb1d643a30a5f6cc9950526e81 = 'u-password'; $ve57492e1c3bb8975edf9399351741cf8 = 'u-password-md5'; $v0a7cb1c6ec211bc445c36725ebfb7bab = 'u-session-id'; $v50b6116b0f49a6cb34e310d17da0ccc4 = ini_get("session.name"); if ($v870fd5468174f846789cb0d56d95bed7 = getCookie($v2b2dccfdbf6e767de8512d66da6d18ca)) { if ($v61b14997da4f52f41ee7b0d90f09e670 = getCookie($vad1ffbcb1d643a30a5f6cc9950526e81)) { $v61b14997da4f52f41ee7b0d90f09e670 = md5($v61b14997da4f52f41ee7b0d90f09e670); } else { $v61b14997da4f52f41ee7b0d90f09e670 = getCookie($ve57492e1c3bb8975edf9399351741cf8); } } if (function_exists('apache_request_headers')) { $v47722c9511693b9a32d48982e48a7b9b = apache_request_headers(); if (isset($v47722c9511693b9a32d48982e48a7b9b[$v2b2dccfdbf6e767de8512d66da6d18ca])) { $v870fd5468174f846789cb0d56d95bed7 = umiObjectProperty::filterInputString(str_replace(chr(0), "", $v47722c9511693b9a32d48982e48a7b9b[$v2b2dccfdbf6e767de8512d66da6d18ca])); } if (isset($v47722c9511693b9a32d48982e48a7b9b[$ve57492e1c3bb8975edf9399351741cf8])) { $v61b14997da4f52f41ee7b0d90f09e670 = umiObjectProperty::filterInputString(str_replace(chr(0), "", $v47722c9511693b9a32d48982e48a7b9b[$ve57492e1c3bb8975edf9399351741cf8])); } elseif (isset($v47722c9511693b9a32d48982e48a7b9b[$vad1ffbcb1d643a30a5f6cc9950526e81])) { $v61b14997da4f52f41ee7b0d90f09e670 = md5(umiObjectProperty::filterInputString(str_replace(chr(0), "", $v47722c9511693b9a32d48982e48a7b9b[$vad1ffbcb1d643a30a5f6cc9950526e81]))); } if (isset($v47722c9511693b9a32d48982e48a7b9b[$v0a7cb1c6ec211bc445c36725ebfb7bab])) { $ve218c54eefdbe103350435489a6595cb = umiObjectProperty::filterInputString(str_replace(chr(0), "", $v47722c9511693b9a32d48982e48a7b9b[$v0a7cb1c6ec211bc445c36725ebfb7bab])); } } if (isset($_POST[$v2b2dccfdbf6e767de8512d66da6d18ca])) { $v870fd5468174f846789cb0d56d95bed7 = umiObjectProperty::filterInputString(str_replace(chr(0), "", $_POST[$v2b2dccfdbf6e767de8512d66da6d18ca])); } if (isset($_POST[$ve57492e1c3bb8975edf9399351741cf8])) { $v61b14997da4f52f41ee7b0d90f09e670 = umiObjectProperty::filterInputString(str_replace(chr(0), "", $_POST[$ve57492e1c3bb8975edf9399351741cf8])); } elseif (isset($_POST[$vad1ffbcb1d643a30a5f6cc9950526e81])) { $v61b14997da4f52f41ee7b0d90f09e670 = md5(umiObjectProperty::filterInputString(str_replace(chr(0), "", $_POST[$vad1ffbcb1d643a30a5f6cc9950526e81]))); } if (isset($_POST[$v0a7cb1c6ec211bc445c36725ebfb7bab])) { $ve218c54eefdbe103350435489a6595cb = umiObjectProperty::filterInputString(str_replace(chr(0), "", $_POST[$v0a7cb1c6ec211bc445c36725ebfb7bab])); } if (isset($_GET[$v2b2dccfdbf6e767de8512d66da6d18ca])) { $v870fd5468174f846789cb0d56d95bed7 = umiObjectProperty::filterInputString(str_replace(chr(0), "", $_GET[$v2b2dccfdbf6e767de8512d66da6d18ca])); } if (isset($_GET[$ve57492e1c3bb8975edf9399351741cf8])) { $v61b14997da4f52f41ee7b0d90f09e670 = umiObjectProperty::filterInputString(str_replace(chr(0), "", $_GET[$ve57492e1c3bb8975edf9399351741cf8])); } elseif (isset($_GET[$vad1ffbcb1d643a30a5f6cc9950526e81])) { $v61b14997da4f52f41ee7b0d90f09e670 = md5(umiObjectProperty::filterInputString(str_replace(chr(0), "", $_GET[$vad1ffbcb1d643a30a5f6cc9950526e81]))); } if (isset($_GET[$v0a7cb1c6ec211bc445c36725ebfb7bab])) { $ve218c54eefdbe103350435489a6595cb = umiObjectProperty::filterInputString(str_replace(chr(0), "", $_GET[$v0a7cb1c6ec211bc445c36725ebfb7bab])); } if (strlen($v870fd5468174f846789cb0d56d95bed7) && strlen($v61b14997da4f52f41ee7b0d90f09e670)) { $vf5b788937450a693e6cbec05d8b8b13f = umiObjectTypesCollection::getInstance()->getBaseType("users", "user"); $v8636cb7e3d45cd4e1e8e863d3286393e = umiObjectTypesCollection::getInstance()->getType($vf5b788937450a693e6cbec05d8b8b13f); $v8f671407d6df210b2670166a82e0fc1a = $v8636cb7e3d45cd4e1e8e863d3286393e->getFieldId("login"); $v98fc9fb0068cf0cdca3ce2e0cb0843d6 = $v8636cb7e3d45cd4e1e8e863d3286393e->getFieldId("password"); $v713d1619aba4eeb6679aec2b499e1b33 = $v8636cb7e3d45cd4e1e8e863d3286393e->getFieldId("is_activated"); $v8be74552df93e31bbdd6b36ed74bdb6a = new umiSelection(); $v8be74552df93e31bbdd6b36ed74bdb6a->setLimitFilter(); $v8be74552df93e31bbdd6b36ed74bdb6a->addLimit(1); $v8be74552df93e31bbdd6b36ed74bdb6a->setObjectTypeFilter(); $v8be74552df93e31bbdd6b36ed74bdb6a->addObjectType($vf5b788937450a693e6cbec05d8b8b13f); $v8be74552df93e31bbdd6b36ed74bdb6a->setPropertyFilter(); $v8be74552df93e31bbdd6b36ed74bdb6a->addPropertyFilterEqual($v8f671407d6df210b2670166a82e0fc1a, $v870fd5468174f846789cb0d56d95bed7); $v8be74552df93e31bbdd6b36ed74bdb6a->addPropertyFilterEqual($v98fc9fb0068cf0cdca3ce2e0cb0843d6, $v61b14997da4f52f41ee7b0d90f09e670); $v8be74552df93e31bbdd6b36ed74bdb6a->addPropertyFilterEqual($v713d1619aba4eeb6679aec2b499e1b33, 1); $result = umiSelectionsParser::runSelection($v8be74552df93e31bbdd6b36ed74bdb6a); if (sizeof($result) === 1) { $vbc8a7343779d62b3f0dc86f78848bde1 = intval($result[0]); if (!session_id()) { session_start(); } $vc87c62534434262e1d1c1348215684ef = session_id(); system_runSession(); if (strlen($vc87c62534434262e1d1c1348215684ef) && isset($_SESSION) && isset($_SESSION['cms_login']) && isset($_SESSION['cms_pass']) && isset($_SESSION['user_id']) && $_SESSION['cms_login'] === $v870fd5468174f846789cb0d56d95bed7 && $_SESSION['cms_pass'] === $v61b14997da4f52f41ee7b0d90f09e670 && $_SESSION['user_id'] === $vbc8a7343779d62b3f0dc86f78848bde1) { $_SESSION['starttime'] = time(); return self::PREAUTH_ALREADY; } if (strlen($ve218c54eefdbe103350435489a6595cb)) { if (strlen($vc87c62534434262e1d1c1348215684ef)) { session_destroy(); } session_id($ve218c54eefdbe103350435489a6595cb); session_start(); $_SESSION['starttime'] = time(); if (!(isset($_SESSION['cms_login']) && isset($_SESSION['cms_pass']) && isset($_SESSION['user_id']) && $_SESSION['cms_login'] === $v870fd5468174f846789cb0d56d95bed7 && $_SESSION['cms_pass'] === $v61b14997da4f52f41ee7b0d90f09e670 && $_SESSION['user_id'] === $vbc8a7343779d62b3f0dc86f78848bde1)) { session_destroy(); } else { $vd69634a59b2cc5df7d632e48474afc94 = new umiEventPoint("users_prelogin_successfull"); $vd69634a59b2cc5df7d632e48474afc94->setParam("prelogin_mode", self::PREAUTH_SUCCESS_RESTORE); $vd69634a59b2cc5df7d632e48474afc94->setParam("user_id", $vbc8a7343779d62b3f0dc86f78848bde1); umiEventsController::getInstance()->callEvent($vd69634a59b2cc5df7d632e48474afc94); return self::PREAUTH_SUCCESS_RESTORE; } } else { @session_start(); $_SESSION['cms_login'] = $v870fd5468174f846789cb0d56d95bed7; $_SESSION['cms_pass'] = $v61b14997da4f52f41ee7b0d90f09e670; $_SESSION['user_id'] = $vbc8a7343779d62b3f0dc86f78848bde1; $v41275a535677f79ff347e01bc530c176 = permissionsCollection::getInstance(); if ($v41275a535677f79ff347e01bc530c176->isSv($vbc8a7343779d62b3f0dc86f78848bde1)) { $_SESSION['user_is_sv'] = true; } session_commit(); session_start(); $_SESSION['starttime'] = time(); $vd69634a59b2cc5df7d632e48474afc94 = new umiEventPoint("users_prelogin_successfull"); $vd69634a59b2cc5df7d632e48474afc94->setParam("prelogin_mode", self::PREAUTH_SUCCESS_NEW); $vd69634a59b2cc5df7d632e48474afc94->setParam("user_id", $vbc8a7343779d62b3f0dc86f78848bde1); umiEventsController::getInstance()->callEvent($vd69634a59b2cc5df7d632e48474afc94); if (isset($_REQUEST['u-login-store']) && (intval($_REQUEST['u-login-store']) || strtoupper($_REQUEST['u-login-store']) === 'ON')) { setcookie($v2b2dccfdbf6e767de8512d66da6d18ca, $v870fd5468174f846789cb0d56d95bed7, time() + 60 * 60 * 24 * 31, "/"); setcookie($ve57492e1c3bb8975edf9399351741cf8, $v61b14997da4f52f41ee7b0d90f09e670, time() + 60 * 60 * 24 * 31, "/"); } return self::PREAUTH_SUCCESS_NEW; } } } return self::PREAUTH_INVALID; }
public function projects($template = "default", $limit = false, $ignore_paging = false) { list($template_block, $template_block_empty, $template_line) = def_module::loadTemplates("faq/".$template, "projects_block", "projects_block_empty", "projects_block_line"); $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("faq", "project")->getId(); $per_page = ($limit) ? $limit : $this->per_page; $curr_page = (int) getRequest('p'); if($ignore_paging) $curr_page = 0; $sel = new umiSelection; $sel->addElementType($hierarchy_type_id); $sel->addLimit($per_page, $curr_page); $sel->addPermissions(); $result = umiSelectionsParser::runSelection($sel); $total = umiSelectionsParser::runSelectionCounts($sel); if(($sz = sizeof($result)) > 0) { $block_arr = Array(); $lines = Array(); for($i = 0; $i < $sz; $i++) { if ($i < $limit || $limit === false) { $element_id = $result[$i]; $element = umiHierarchy::getInstance()->getElement($element_id); if(!$element) continue; $line_arr = Array(); $line_arr['attribute:id'] = $element_id; $line_arr['attribute:name'] = $line_arr['void:text'] = $element->getName(); $line_arr['void:alt_name'] = $element->getAltName(); $line_arr['attribute:link'] = $element->link; $line_arr['xlink:href'] = "upage://" . $element_id; $this->pushEditable("faq", "project", $element_id); $lines[] = self::parseTemplate($template_line, $line_arr, $element_id); } } $block_arr['subnodes:lines'] = $lines; $block_arr['total'] = $total; $block_arr['per_page'] = $per_page; return self::parseTemplate($template_block, $block_arr); } else { return $template_block_empty; } }
public function album($path = false, $template = "default", $limit = false, $ignore_paging = false) { $curr_page = (int) getRequest('p'); $per_page = $limit ? $limit : $this->per_page; if ($ignore_paging) { $curr_page = 0; } $element_id = $this->analyzeRequiredPath($path); if ($element_id === false && $path != KEYWORD_GRAB_ALL) { throw new publicException(getLabel('error-page-does-not-exist', null, $path)); } list($template_block, $template_block_empty, $template_line) = def_module::loadTemplates("photoalbum/" . $template, "album_block", "album_block_empty", "album_block_line"); $block_arr = array(); $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("photoalbum", "photo")->getId(); $sel = new umiSelection(); $sel->addElementType($hierarchy_type_id); if ($path != KEYWORD_GRAB_ALL) { $sel->addHierarchyFilter($element_id); } $sel->addPermissions(); $sel->addLimit($per_page, $curr_page); $result = umiSelectionsParser::runSelection($sel); $total = umiSelectionsParser::runSelectionCounts($sel); $block_arr['id'] = $block_arr['void:album_id'] = $element_id; $lines = array(); if ($total > 0) { foreach ($result as $photo_element_id) { $line_arr = array(); $photo_element = umiHierarchy::getInstance()->getElement($photo_element_id); if (!$photo_element) { continue; } $line_arr['attribute:id'] = $photo_element_id; $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($photo_element_id); $line_arr['xlink:href'] = "upage://" . $photo_element_id; $line_arr['node:name'] = $photo_element->getName(); $this->pushEditable("photoalbum", "photo", $photo_element_id); $lines[] = self::parseTemplate($template_line, $line_arr, $photo_element_id); } } else { return self::parseTemplate($template_block_empty, $block_arr, $element_id); } $block_arr['subnodes:items'] = $block_arr['void:lines'] = $lines; $block_arr['total'] = $total; $block_arr['per_page'] = $per_page; $block_arr['link'] = umiHierarchy::getInstance()->getPathById($element_id); return self::parseTemplate($template_block, $block_arr, $element_id); }
public function pages_mklist_by_tags($s_tags, $i_domain_id = NULL, $s_template = "tags", $i_per_page = false, $b_ignore_paging = false, $s_base_types = '') { /* */ // init and context : $s_tpl_pages = "pages"; $s_tpl_page = "page"; $s_tpl_pages_empty = "pages_empty"; // validate input : $i_per_page = intval($i_per_page); if (!$i_per_page) { $i_per_page = 10; } if ($i_per_page === -1) { $b_ignore_paging = true; } $s_template = strval($s_template); if (!strlen($s_template)) { $s_template = "tags"; } $i_curr_page = intval(getRequest('p')); if ($b_ignore_paging) { $i_curr_page = 0; } $s_base_types = strval($s_base_types); // load templates : list($tpl_pages, $tpl_page, $tpl_pages_empty) = def_module::loadTemplates("content/" . $s_template, $s_tpl_pages, $s_tpl_page, $s_tpl_pages_empty); // process : $o_sel = new umiSelection(); if ($i_domain_id) { $o_sel->setIsDomainIgnored(false); } else { $o_sel->setIsDomainIgnored(true); } if (strlen($s_base_types)) { $o_sel->setElementTypeFilter(); $arr_base_types = preg_split("/\\s+/is", $s_base_types); foreach ($arr_base_types as $s_next_type) { $arr_next_type = explode('.', $s_next_type); if (count($arr_next_type) === 2) { $o_hierarchy_type = umiHierarchyTypesCollection::getInstance()->getTypeByName($arr_next_type[0], $arr_next_type[1]); if ($o_hierarchy_type instanceof umiHierarchyType) { $i_hierarchy_type_id = $o_hierarchy_type->getId(); $o_sel->addElementType($i_hierarchy_type_id); } } } } $o_sel->forceHierarchyTable(); $o_object_type = umiObjectTypesCollection::getInstance()->getTypeByGUID('root-pages-type'); $i_tags_field_id = $o_object_type->getFieldId('tags'); $arr_tags = preg_split("/\\s*,\\s*/is", $s_tags); $o_sel->setPropertyFilter(); $o_sel->addPropertyFilterEqual($i_tags_field_id, $arr_tags); $o_sel->setPermissionsFilter(); $o_sel->addPermissions(); if ($i_per_page !== -1) { $o_sel->setLimitFilter(); $o_sel->addLimit($i_per_page, $i_curr_page); } $result = umiSelectionsParser::runSelection($o_sel); $total = umiSelectionsParser::runSelectionCounts($o_sel); $block_arr = array(); if (($sz = sizeof($result)) > 0) { $arr_items = array(); for ($i = 0; $i < $sz; $i++) { $line_arr = array(); $element_id = intval($result[$i]); $element = umiHierarchy::getInstance()->getElement($element_id); if (!$element) { continue; } $line_arr['attribute:id'] = $element_id; $line_arr['node:name'] = $element->getName(); $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($element_id); $line_arr['void:header'] = $lines_arr['name'] = $element->getName(); if ($publish_time = $element->getValue('publish_time')) { $line_arr['attribute:publish_time'] = $publish_time->getFormattedDate("U"); } $arr_items[] = def_module::parseTemplate($tpl_page, $line_arr, $element_id); umiHierarchy::getInstance()->unloadElement($element_id); } $block_arr['subnodes:items'] = $arr_items; $block_arr['tags'] = $s_tags; $block_arr['total'] = $total; $block_arr['per_page'] = $i_per_page; return def_module::parseTemplate($tpl_pages, $block_arr); } else { return def_module::parseTemplate($tpl_pages_empty, $block_arr); } }
public function insertlast($template = "default") { if (!$template) { $template = "default"; } $type_id = umiObjectTypesCollection::getInstance()->getBaseType("vote", "poll"); $type = umiObjectTypesCollection::getInstance()->getType($type_id); $time_field_id = $type->getFieldId("publish_time"); $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("vote", "poll")->getId(); $sel = new umiSelection(); $sel->setHierarchyFilter(); $sel->addElementType($hierarchy_type_id); $sel->setLimitFilter(); $sel->addLimit(1); $sel->setOrderFilter(); $sel->setOrderByProperty($time_field_id, false); $sel->addPermissions(); $sel->forceHierarchyTable(); $result = umiSelectionsParser::runSelection($sel); if (sizeof($result)) { list($element_id) = $result; } else { $element_id = false; } if ($element_id) { return $this->poll($element_id, $template); } }
public function getCategoryList($template = "default", $category_id = false, $limit = false, $ignore_paging = false, $i_need_deep = 0) { if (!$template) { $template = "default"; } list($template_block, $template_block_empty, $template_line) = def_module::loadTemplates("catalog/" . $template, "category_block", "category_block_empty", "category_block_line"); if (!$i_need_deep) { $i_need_deep = intval(getRequest('param4')); } if (!$i_need_deep) { $i_need_deep = 0; } $i_need_deep = intval($i_need_deep); if ($i_need_deep === -1) { $i_need_deep = 100; } if ((string) $category_id != '0') { $category_id = $this->analyzeRequiredPath($category_id); } $social_module = cmsController::getInstance()->getModule("social_networks"); if ($social_module) { $social = $social_module->getCurrentSocial(); } else { $social = false; } if ($category_id === false) { throw new publicException(getLabel('error-page-does-not-exist', null, $category_id)); } $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("catalog", "category")->getId(); $per_page = $limit ? $limit : $this->per_page; $curr_page = (int) getRequest('p'); if ($ignore_paging) { $curr_page = 0; } $sel = new umiSelection(); $sel->addElementType($hierarchy_type_id); $sel->addHierarchyFilter($category_id, $i_need_deep); $sel->addLimit($per_page, $curr_page); $result = umiSelectionsParser::runSelection($sel); $total = umiSelectionsParser::runSelectionCounts($sel); if (($sz = sizeof($result)) > 0) { $block_arr = array(); $lines = array(); for ($i = 0; $i < $sz; $i++) { if ($i < $limit || $limit == false) { $element_id = $result[$i]; if ($social && !$social->isHierarchyAllowed($result[$i])) { continue; } $element = umiHierarchy::getInstance()->getElement($element_id); if (!$element) { continue; } $line_arr = array(); $line_arr['attribute:id'] = $element_id; $line_arr['void:alt_name'] = $element->getAltName(); $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($element_id); $line_arr['xlink:href'] = "upage://" . $element_id; $line_arr['node:text'] = $element->getName(); $lines[] = self::parseTemplate($template_line, $line_arr, $element_id); } } $block_arr['attribute:category-id'] = $block_arr['void:category_id'] = $category_id; $block_arr['subnodes:items'] = $block_arr['void:lines'] = $lines; $block_arr['total'] = $total; $block_arr['per_page'] = $per_page; return self::parseTemplate($template_block, $block_arr, $category_id); } else { $block_arr = array(); $block_arr['attribute:category-id'] = $block_arr['void:category_id'] = $category_id; return self::parseTemplate($template_block_empty, $block_arr, $category_id); } }
public function getCategoryList($template = "default", $category_id = false, $limit = false, $ignore_paging = false, $i_need_deep = 0) { // первый параметр Шаблон, по которому выводятся подразделы. В XSLT-шаблонизаторе игнорируется if (!$template) { $template = "default"; } // Присвоить переменным из списка значения // Получаем блоки шаблонов "category_block", "category_block_empty", "category_block_line" из файла шаблона $template, из папки "catalog/.$template ". list($template_block, $template_block_empty, $template_line) = def_module::loadTemplates("catalog/" . $template, "category_block", "category_block_empty", "category_block_line"); // Глубина поиска объектов по умолчанию в текущем if (!$i_need_deep) { $i_need_deep = intval(getRequest('param4')); } if (!$i_need_deep) { $i_need_deep = 0; } $i_need_deep = intval($i_need_deep); if ($i_need_deep === -1) { $i_need_deep = 100; } // идентификатор или путь до раздела каталога if ((string) $category_id != '0') { $category_id = $this->analyzeRequiredPath($category_id); } /** * @var social_networks $social_module */ // получить модуль $social_module = cmsController::getInstance()->getModule("social_networks"); if ($social_module) { $social = $social_module->getCurrentSocial(); } else { $social = false; } // Нет пути исключение if ($category_id === false) { throw new publicException(getLabel('error-page-does-not-exist', null, $category_id)); } //Получаем id иерархического типа $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("catalog", "category")->getId(); // количество элементов на странице $per_page = $limit ? $limit : $this->per_page; // текщая страница $curr_page = (int) getRequest('p'); // Игнорировать переход по страницам if ($ignore_paging) { $curr_page = 0; } // назначить выборку $sel = new umiSelection(); // отбор заданных элементов $sel->addElementType($hierarchy_type_id); // начиная с заданного раздела и глубиной $sel->addHierarchyFilter($category_id, $i_need_deep); // количество объектов и номер страгницы $sel->addLimit($per_page, $curr_page); $result = umiSelectionsParser::runSelection($sel); $total = umiSelectionsParser::runSelectionCounts($sel); // Если в выборке присутствуют элементы if (($sz = sizeof($result)) > 0) { // массив с общей информацией по выборке $block_arr = array(); // массив выбранных элементов $lines = array(); for ($i = 0; $i < $sz; $i++) { // пока не достигнут лимит if ($i < $limit || $limit == false) { // получить id элемента из результата $element_id = $result[$i]; // ???? if ($social && !$social->isHierarchyAllowed($result[$i])) { // следующий цикл continue; } $element = umiHierarchy::getInstance()->getElement($element_id); // неопределён элемент -> следующий цикл if (!$element) { continue; } // массив свойств элемента $line_arr = array(); $line_arr['attribute:id'] = $element_id; $line_arr['void:alt_name'] = $element->getAltName(); $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($element_id); $line_arr['xlink:href'] = "upage://" . $element_id; $line_arr['node:text'] = $element->getName(); // построить результат по шаблону $lines[] = self::parseTemplate($template_line, $line_arr, $element_id); } } $block_arr['attribute:category-id'] = $block_arr['void:category_id'] = $category_id; $block_arr['subnodes:items'] = $block_arr['void:lines'] = $lines; $block_arr['total'] = $total; $block_arr['per_page'] = $per_page; // вернуть результат return self::parseTemplate($template_block, $block_arr, $category_id); } else { // пустая выборка $block_arr = array(); $block_arr['attribute:category-id'] = $block_arr['void:category_id'] = $category_id; return self::parseTemplate($template_block_empty, $block_arr, $category_id); } }
public function getFilteredPages($v94757cae63fd3e398c0811a976dd6bbe, $vdfc394bd05a4b48161c790034af522a8, $v2063c1608d6e0baf80249c42e2be5804, $v9d85c254b5062e518a134a61950999c3 = 10, $v66f6181bcb4cff4cd38fbc804a036db6 = "default", $v126424c808da347218ba631a78feaf04 = false, $v3aabf39f2d943fa886d86dcbbee4d910 = false, $v375a52cb87b22005816fe7a418ec6660 = true) { $ve1ba980ce14a8c0d7e2779f895ab8695 = getRequest('p'); if ($v126424c808da347218ba631a78feaf04) { $ve1ba980ce14a8c0d7e2779f895ab8695 = 0; } list($v364f9b183bd2dd9e0beb45c754830a6c, $ve6a2fd7211958cfe50efa4d14bd332f5, $v28d65bb7a643774ada22f54ca0679289) = def_module::loadTemplates("filtered_pages/" . $v66f6181bcb4cff4cd38fbc804a036db6, "pages_block", "pages_block_line", "pages_block_empty"); $v599dcce2998a6b40b1e38e8c6006cb0a = umiObjectTypesCollection::getInstance()->getType($v94757cae63fd3e398c0811a976dd6bbe); if ($v599dcce2998a6b40b1e38e8c6006cb0a instanceof umiObjectType) { if ($vf8a30f899e9d691c760031d60ea0f3a2 = $v599dcce2998a6b40b1e38e8c6006cb0a->getFieldId($vdfc394bd05a4b48161c790034af522a8)) { $v8be74552df93e31bbdd6b36ed74bdb6a = new umiSelection(); $v8be74552df93e31bbdd6b36ed74bdb6a->forceHierarchyTable(true); $v8be74552df93e31bbdd6b36ed74bdb6a->addObjectType($v94757cae63fd3e398c0811a976dd6bbe); $v06e3d36fa30cea095545139854ad1fb9 = umiFieldsCollection::getInstance()->getField($vf8a30f899e9d691c760031d60ea0f3a2); if ($v051369818a8073bba5feeb0e957eb308 = $v06e3d36fa30cea095545139854ad1fb9->getGuideId()) { if (!is_numeric($v2063c1608d6e0baf80249c42e2be5804)) { $vd47c20d305d6a44856735d5fe5c086ca = umiObjectsCollection::getInstance()->getGuidedItems($v051369818a8073bba5feeb0e957eb308); $v2063c1608d6e0baf80249c42e2be5804 = array_search($v2063c1608d6e0baf80249c42e2be5804, $vd47c20d305d6a44856735d5fe5c086ca); } } $v8be74552df93e31bbdd6b36ed74bdb6a->addPropertyFilterEqual($vf8a30f899e9d691c760031d60ea0f3a2, $v2063c1608d6e0baf80249c42e2be5804); $v8be74552df93e31bbdd6b36ed74bdb6a->addPermissions(); $v8be74552df93e31bbdd6b36ed74bdb6a->addLimit($v9d85c254b5062e518a134a61950999c3, $ve1ba980ce14a8c0d7e2779f895ab8695); $v8be74552df93e31bbdd6b36ed74bdb6a->addActiveFilter(true); if ($v3aabf39f2d943fa886d86dcbbee4d910) { $v8be74552df93e31bbdd6b36ed74bdb6a->setOrderByProperty($v3aabf39f2d943fa886d86dcbbee4d910, $v375a52cb87b22005816fe7a418ec6660); } else { $v8be74552df93e31bbdd6b36ed74bdb6a->setOrderByObjectId($v375a52cb87b22005816fe7a418ec6660); } $result = umiSelectionsParser::runSelection($v8be74552df93e31bbdd6b36ed74bdb6a); $vfbb44b4487415b134bce9c790a27fe5e = umiSelectionsParser::runSelectionCounts($v8be74552df93e31bbdd6b36ed74bdb6a); $vfca1bff8ad8b3a8585abfb0ad523ba42 = array(); if ($vfbb44b4487415b134bce9c790a27fe5e > 0) { $v691d502cfd0e0626cd3b058e5682ad1c = array(); $v12a673c3eb40ea95d992c775443b8709 = umiHierarchy::getInstance(); foreach ($result as $v7057e8409c7c531a1a6e9ac3df4ed549) { $v8e2dcfd7e7e24b1ca76c1193f645902b = $v12a673c3eb40ea95d992c775443b8709->getElement($v7057e8409c7c531a1a6e9ac3df4ed549); if ($v8e2dcfd7e7e24b1ca76c1193f645902b instanceof umiHierarchyElement) { $v691d502cfd0e0626cd3b058e5682ad1c[] = def_module::parseTemplate($ve6a2fd7211958cfe50efa4d14bd332f5, array('attribute:id' => $v8e2dcfd7e7e24b1ca76c1193f645902b->id, 'attribute:link' => $v8e2dcfd7e7e24b1ca76c1193f645902b->link, 'node:name' => $v8e2dcfd7e7e24b1ca76c1193f645902b->name)); } } $vfca1bff8ad8b3a8585abfb0ad523ba42['subnodes:items'] = $v691d502cfd0e0626cd3b058e5682ad1c; $v66f6181bcb4cff4cd38fbc804a036db6 = $v364f9b183bd2dd9e0beb45c754830a6c; } else { $v66f6181bcb4cff4cd38fbc804a036db6 = $v28d65bb7a643774ada22f54ca0679289; } $vfca1bff8ad8b3a8585abfb0ad523ba42['total'] = $vfbb44b4487415b134bce9c790a27fe5e; $vfca1bff8ad8b3a8585abfb0ad523ba42['per_page'] = $v9d85c254b5062e518a134a61950999c3; return def_module::parseTemplate($v66f6181bcb4cff4cd38fbc804a036db6, $vfca1bff8ad8b3a8585abfb0ad523ba42); } else { throw new publicException("Type \"" . $v599dcce2998a6b40b1e38e8c6006cb0a->getName() . "\" doesn't have property \"{$vdfc394bd05a4b48161c790034af522a8}\""); } } else { throw new publicException("Wrong type id \"{$v94757cae63fd3e398c0811a976dd6bbe}\""); } }
/** * @desc Выводит список черновиков текущего пользователя * @param Int $blogId Идентификатор блога * @param String $template Имя файла шаблона для вывода * @return string|array */ public function draughtsList($blogId = false, $template = 'default', $limit = false) { list($sTemplateBlock, $sTemplateLine) = self::loadTemplates('blogs20/' . $template, 'posts_list_block', 'posts_list_line'); $page = (int) getRequest('p'); $oBlog = null; $oHierarchy = umiHierarchy::getInstance(); if ($blogId === false) { $iTmp = getRequest('param0'); if ($iTmp) { $blogId = (int) $iTmp; } } $hierarchyTypes = umiHierarchyTypesCollection::getInstance(); $blogHierachyTypeId = $hierarchyTypes->getTypeByName("blogs20", "blog")->getId(); $sel = new umiSelection(); $hierarchy_type_id = $hierarchyTypes->getTypeByName("blogs20", "post")->getId(); $sel->addElementType($hierarchy_type_id); $typesCollection = umiObjectTypesCollection::getInstance(); $typeId = $typesCollection->getTypeByHierarchyTypeId($hierarchy_type_id); $postType = $typesCollection->getType($typeId); $userId = cmsController::getInstance()->getModule('users')->user_id; $sel->addOwnerFilter(array($userId)); if ($blogId !== false) { $oBlog = $oHierarchy->getElement($blogId); if ($oBlog && $oBlog->getHierarchyType() == $blogHierachyTypeId) { $sel->addHierarchyFilter($blogId); } } $sel->addActiveFilter(false); $sel->setOrderByProperty($postType->getFieldId('publish_time'), false); $sel->addLimit($limit ? $limit : $this->posts_per_page, $page); self::applyTimeRange($sel, $postType); $result = umiSelectionsParser::runSelection($sel); $total = umiSelectionsParser::runSelectionCounts($sel); $aLines = array(); foreach ($result as $iPostId) { $oPost = $oHierarchy->getElement($iPostId); if (!$oPost) { continue; } if (!$oBlog) { $oBlog = $oHierarchy->getElement($oPost->getRel()); } if (!$oBlog) { continue; } $sPostLink = '/blogs20/postView/' . $iPostId . '/'; $sBlogLink = $oHierarchy->getPathById($oBlog->getId(), true); $aLineParam = array(); $aLineParam['attribute:id'] = $iPostId; $aLineParam['attribute:author_id'] = $oPost->getObject()->getOwnerId(); $aLineParam['node:name'] = $oPost->getName(); $aLineParam['post_link'] = $sPostLink; $aLineParam['blog_link'] = $sBlogLink; $aLineParam['bid'] = $oBlog->getId(); $aLineParam['blog_title'] = $oBlog->getValue('title'); $aLineParam['title'] = $oPost->getValue('title'); $aLineParam['content'] = $oPost->getValue('content'); $aLineParam['cut'] = $this->prepareCut($aLineParam['content'], $sPostLink, $template); $aLineParam['subnodes:tags'] = $this->prepareTags($oPost->getValue('tags')); $aLineParam['comments_count'] = $oHierarchy->getChildsCount($iPostId, false); $this->pushEditable("blogs20", "post", $iPostId); $aLines[] = self::parseTemplate($sTemplateLine, $aLineParam, $iPostId); } $aBlockParam = array(); $aBlockParam['void:lines'] = $aBlockParam['subnodes:items'] = $aLines; $aBlockParam['bid'] = $blogId; $aBlockParam['per_page'] = $limit ? $limit : $this->posts_per_page; $aBlockParam['total'] = $total; return self::parseTemplate($sTemplateBlock, $aBlockParam); }
public function lastlents($elementPath, $template = "default", $per_page = false, $ignore_paging = false) { if (!$per_page) { $per_page = $this->per_page; } list($template_block, $template_block_empty, $template_line, $template_archive) = def_module::loadTemplates("news/" . $template, "listlents_block", "listlents_block_empty", "listlents_item", "listlents_archive"); $curr_page = (int) getRequest('p'); if ($ignore_paging) { $curr_page = 0; } $parent_id = $this->analyzeRequiredPath($elementPath); if ($parent_id === false) { throw new publicException(getLabel('error-page-does-not-exist', null, $elementPath)); } $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("news", "rubric")->getId(); $sel = new umiSelection(); $sel->addElementType($hierarchy_type_id); $sel->addHierarchyFilter($parent_id, 0, true); $sel->addPermissions(); $sel->addLimit($per_page, $curr_page); $result = umiSelectionsParser::runSelection($sel); $total = umiSelectionsParser::runSelectionCounts($sel); if (($sz = sizeof($result)) > 0) { $block_arr = array(); $lines = array(); for ($i = 0; $i < $sz; $i++) { $line_arr = array(); $element_id = $result[$i]; $element = umiHierarchy::getInstance()->getElement($element_id); $line_arr['attribute:id'] = $element_id; $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($element_id); $line_arr['xlink:href'] = "upage://" . $element_id; $line_arr['void:header'] = $lines_arr['name'] = $element->getName(); $line_arr['node:name'] = $element->getName(); $lines[] = self::parseTemplate($template_line, $line_arr, $element_id); $this->pushEditable("news", "rubric", $element_id); } if (is_array($parent_id)) { list($parent_id) = $parent_id; } $block_arr['subnodes:items'] = $block_arr['void:lines'] = $lines; $block_arr['total'] = $total; $block_arr['per_page'] = $per_page; return self::parseTemplate($template_block, $block_arr, $parent_id); } else { return $template_block_empty; } }
public function is_auth() { static $is_auth; if($is_auth === false || $is_auth === true) { return $is_auth; } $guest_id = umiObjectsCollection::getInstance()->getObjectIdByGUID('system-guest'); $user_id = getSession('user_id'); $login = getSession('cms_login'); $pass = getSession('cms_pass'); $this->user_login = "******"; $this->user_fullname = "%users_anonymous_fullname%"; if($user_id) { if($user_id == $guest_id) { $this->user_id = $user_id; return $is_auth = false; } else { $user = umiObjectsCollection::getInstance()->getObject($user_id); if($user instanceof umiObject) { if($pass != $user->getValue('password')) { unset($_SESSION['user_id']); $this->user_id = $guest_id; return $is_auth = false; } $login = $user->getValue('login'); $fname = $user->getValue('fname'); $lname = $user->getValue('lname'); $groups = $user->getValue('groups'); $this->groups = $groups; $this->user_id = $user_id; $this->user_login = $login; $this->user_fullname = "{$fname} {$lname}"; $this->updateUserLastRequestTime($user_id); system_runSession(); return $is_auth = true; } } } if($login && $pass) { $objectTypes = umiObjectTypesCollection::getInstance(); $object_type_id = $objectTypes->getBaseType("users", "user"); $object_type = $objectTypes->getType($object_type_id); $login_field_id = $object_type->getFieldId("login"); $password_field_id = $object_type->getFieldId("password"); $sel = new umiSelection; $sel->addLimit(1); $sel->addObjectType($objectTypes->getChildClasses($object_type_id)); $sel->addPropertyFilterEqual($login_field_id, $login); $sel->addPropertyFilterEqual($password_field_id, $pass); $result = umiSelectionsParser::runSelection($sel); } else { $result = Array(); } if(sizeof($result) == 1) { $user_id = $result[0]; $user_object = umiObjectsCollection::getInstance()->getObject($user_id); $login = $user_object->getValue("login"); $fname = $user_object->getValue("fname"); $lname = $user_object->getValue("lname"); $this->updateUserLastRequestTime($user_id); $groups = $user_object->getValue("groups"); $this->groups = $groups; $this->user_id = $user_id; $this->user_login = $login; $this->user_fullname = "{$fname} {$lname}"; $_SESSION['user_id'] = $user_id; system_runSession(); return $is_auth = true; } else { $this->user_id = $guest_id; $_SESSION['user_id'] = $guest_id; return $is_auth = false; } }
public function activate($template = "default") { if ($this->is_auth()) $this->redirect("/"); if(!$template) $template = "default"; list($template_block, $template_block_failed) = def_module::loadTemplates("users/register/".$template, "activate_block", "activate_block_failed"); $block_arr = Array(); $activate_code = (string) getRequest('param0'); if(!$activate_code || strlen($activate_code) != 32) { throw new publicException("%error_activation_code_failed%"); $template = $template_block_failed; } $typesCollection = umiObjectTypesCollection::getInstance(); $object_type_id = $typesCollection->getBaseType("users", "user"); $object_type = $typesCollection->getType($object_type_id); $childTypes = $typesCollection->getChildClasses($object_type_id); $activate_code_field_id = $object_type->getFieldId("activate_code"); $sel = new umiSelection; $sel->addLimit(1); $sel->addObjectType($object_type_id); $sel->addObjectType($childTypes); $sel->addPropertyFilterEqual($activate_code_field_id, $activate_code); $result = umiSelectionsParser::runSelection($sel); if($result) { list($user_id) = $result; $user = umiObjectsCollection::getInstance()->getObject($user_id); $user->setValue("is_activated", 1); $user->setValue("activate_code", md5(uniqid(rand(), true))); $user->commit(); permissionsCollection::getInstance()->loginAsUser($result); $oEventPoint = new umiEventPoint("users_activate"); $oEventPoint->setMode("after"); $oEventPoint->setParam("user_id", $user_id); $this->setEventPoint($oEventPoint); $template = $template_block; } else { throw new publicException("%error_activation_code_failed%"); $template = $template_block_failed; } return def_module::parseTemplate($template, $block_arr); }