public function createAuthorGuest($nick, $email, $ip) { $objects = umiObjectsCollection::getInstance(); $objectTypes = umiObjectTypesCollection::getInstance(); $nick = trim($nick); $email = trim($email); if (!$nick) { $nick = getLabel('author-anonymous'); } if (!$email) { $email = getServer('REMOTE_ADDR'); } $sel = new selector('objects'); $sel->types('object-type')->name('users', 'author'); $sel->where('email')->equals($email); $sel->where('nickname')->equals($nick); $sel->where('ip')->equals($ip); $sel->limit(0, 1); if ($sel->first) { return $sel->first->id; } else { $user_name = $nick . " ({$email})"; $object_type_id = $objectTypes->getBaseType("users", "author"); $author_id = $objects->addObject($user_name, $object_type_id); $author = $objects->getObject($author_id); $author->name = $user_name; $author->is_registrated = false; $author->nickname = $nick; $author->email = $email; $author->ip = $ip; $author->commit(); return $author_id; } }
public function orders() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } $limit = getRequest('per_page_limit'); $curr_page = (int) getRequest('p'); $offset = $limit * $curr_page; $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'order'); $sel->where('status_id')->isNull(false); $sel->where('name')->notequals('dummy'); $sel->limit($offset, $limit); if (!getRequest('order_filter')) { $sel->order('order_date')->desc(); } selectorHelper::detectFilters($sel); $domains = getRequest('domain_id'); if (is_array($domains) && sizeof($domains)) { $domainsCollection = domainsCollection::getInstance(); if (sizeof($domainsCollection->getList()) > 1) { $sel->where('domain_id')->equals($domains[0]); } } $this->setDataRange($limit, $offset); $data = $this->prepareData($sel->result, "objects"); $this->setData($data, $sel->length); return $this->doData(); }
public function number() { $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'order'); $sel->order('number')->desc(); $sel->limit(0, 1); $number = $sel->first ? $sel->first->number + 1 : 1; $order = $this->order; $order->name = getLabel('order-name-prefix', 'emarket', $number); $order->number = $number; $order->commit(); return $number; }
public function export() { $this->setDataType("list"); $this->setActionType("view"); $limit = getRequest('per_page_limit'); $curr_page = (int) getRequest('p'); $offset = $limit * $curr_page; $sel = new selector('objects'); $sel->types('object-type')->name('exchange', 'export'); $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); $this->setDataRange($limit, $offset); $data = $this->prepareData($sel->result, "objects"); $this->setData($data, $sel->length); return $this->doData(); }
/** * Создать новый пустой заказ * @return Integer $order id нового заказа */ public static function create($useDummyOrder = false) { $objectTypes = umiObjectTypesCollection::getInstance(); $objects = umiObjectsCollection::getInstance(); $permissions = permissionsCollection::getInstance(); $cmsController = cmsController::getInstance(); $domain = $cmsController->getCurrentDomain(); $domainId = $domain->getId(); $orderTypeId = $objectTypes->getBaseType('emarket', 'order'); if ($useDummyOrder) { $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'order'); $sel->where('name')->equals('dummy'); $sel->limit(0, 1); if ($sel->length()) { $orderId = $sel->first->id; } else { $orderTypeId = $objectTypes->getBaseType('emarket', 'order'); $orderId = $objects->addObject('dummy', $orderTypeId); $order = $objects->getObject($orderId); if ($order instanceof iUmiObject == false) { throw new publicException("Can't load dummy object for order #{$orderId}"); } else { $order->setValue('domain_id', $domainId); $order->commit(); } } return self::get($orderId); } $managerId = 0; $statusId = self::getStatusByCode('basket'); $customer = customer::get(); $createTime = time(); $orderId = $objects->addObject('', $orderTypeId); $order = $objects->getObject($orderId); if ($order instanceof iUmiObject == false) { throw new publicException("Can't load created object for order #{$orderId}"); } $order->domain_id = $domainId; $order->manager_id = $managerId; $order->status_id = $statusId; $order->customer_id = $customer->getId(); $order->order_create_date = $createTime; $order->commit(); $customer->setLastOrder($orderId, $domainId); return self::get($orderId); }
public function list_files($element_id = false, $template = "default", $per_page = false, $ignore_paging = false) { if(!$template) $template = "default"; list($template_block, $template_line) = def_module::loadTemplates("filemanager/".$template, "list_files", "list_files_row"); $block_arr = Array(); $element_id = $this->analyzeRequiredPath($element_id); if(!$per_page) $per_page = $this->per_page; $curr_page = (int) getRequest('p'); if($ignore_paging) $curr_page = 0; $sel = new selector('pages'); $sel->types('hierarchy-type')->name('filemanager', 'shared_file'); $sel->where('hierarchy')->page($element_id)->childs(100); $sel->limit($curr_page, $per_page); $result = $sel->result(); $total = $sel->length(); $lines = Array(); foreach($result as $element) { $line_arr = Array(); $next_element_id = $element->getId(); $line_arr['attribute:id'] = $element->getId(); $line_arr['attribute:name'] = $element->getName(); $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($next_element_id); $line_arr['attribute:downloads-count'] = $element->getValue('downloads_counter'); $line_arr['xlink:download-link'] = $this->pre_lang . "/filemanager/download/" . $next_element_id; $line_arr['xlink:href'] = "upage://" . $next_element_id; $line_arr['node:desc'] = $element->getValue("content"); $this->pushEditable("filemanager", "shared_file", $next_element_id); $lines[] = self::parseTemplate($template_line, $line_arr, $next_element_id); } $block_arr['nodes:items'] = $block_arr['void:lines'] = $lines; $block_arr['per_page'] = $per_page; $block_arr['total'] = $total; return self::parseTemplate($template_block, $block_arr); }
public function stores() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } $limit = getRequest('per_page_limit'); $curr_page = (int) getRequest('p'); $offset = $curr_page * $limit; $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'store'); $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); $this->setDataRange($limit, $offset); $data = $this->prepareData($sel->result, "objects"); $this->setData($data, $sel->length); return $this->doData(); }
public function lists() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } $limit = getRequest('per_page_limit'); $curr_page = (int) getRequest('p'); $offset = $limit * $curr_page; $sel = new selector('pages'); $sel->types('hierarchy-type')->name('vote', 'poll'); $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); $this->setDataRange($limit, $offset); $data = $this->prepareData($sel->result, "pages"); $this->setData($data, $sel->length); return $this->doData(); }
function pages($parentId, $properties = array(), $sortings = array(), $limit = false) { $depth = 1; if (!empty($properties['hierarchy_depth'])) { $depth = (int) $properties['hierarchy_depth']; unset($properties['hierarchy_depth']); } $pages = new \selector('pages'); $pages->types('hierarchy-type')->name('content', 'page'); $pages->where('hierarchy')->page($parentId)->childs($depth); foreach ($sortings as $sorting) { if ($sorting == 'rand') { $pages->order('rand'); } } if ($limit) { $pages->limit(0, $limit); } return select($pages, $properties); }
public function last_messages() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } $limit = getRequest('per_page_limit'); $curr_page = getRequest('p'); $offset = $curr_page * $limit; $sel = new selector('pages'); $sel->types('hierarchy-type')->name('forum', 'message'); $sel->order('publish_time')->desc(); $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); $data = $this->prepareData($sel->result, "pages"); $this->setData($data, $sel->length); $this->setDataRangeByPerPage($limit, $curr_page); return $this->doData(); }
public function albums($template = "default", $limit = false, $ignore_paging = false, $parentElementId = false, $order = 'asc') { list($template_block, $template_block_empty, $template_line) = def_module::loadTemplates("photoalbum/" . $template, "albums_list_block", "albums_list_block_empty", "albums_list_block_line"); $block_arr = array(); $curr_page = (int) getRequest('p'); if ($ignore_paging) { $curr_page = 0; } $offset = $limit * $curr_page; $sel = new selector('pages'); $sel->types('hierarchy-type')->name('photoalbum', 'album'); $sel->where('permissions'); if ($parentElementId) { $sel->where('hierarchy')->page($parentElementId)->childs(1); } if (in_array($order, array('asc', 'desc', 'rand'))) { $sel->order('ord')->{$order}(); } $sel->limit($offset, $limit); $result = $sel->result; $total = $sel->length(); $lines = array(); if ($total > 0) { foreach ($result as $element) { $line_arr = array(); $element_id = $element->getId(); $line_arr['attribute:id'] = $element_id; $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($element_id); $line_arr['xlink:href'] = "upage://" . $element_id; $line_arr['node:name'] = $element->getName(); $this->pushEditable("photoalbum", "album", $element_id); $lines[] = self::parseTemplate($template_line, $line_arr, $element_id); } } else { return self::parseTemplate($template_block_empty, $block_arr); } $block_arr['subnodes:items'] = $block_arr['void:lines'] = $lines; $block_arr['total'] = $total; $block_arr['per_page'] = $limit; return self::parseTemplate($template_block, $block_arr); }
public function lists() { $this->setDataType("list"); $this->setActionType("view"); $this->generatePicasaButton(); if ($this->ifNotXmlMode()) { return $this->doData(); } $limit = getRequest('per_page_limit'); $curr_page = getRequest('p'); $offset = $curr_page * $limit; $sel = new selector('pages'); $sel->types('hierarchy-type')->name('photoalbum', 'album'); $sel->types('hierarchy-type')->name('photoalbum', 'photo'); $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); $data = $this->prepareData($sel->result, "pages"); $this->setData($data, $sel->length); $this->setDataRangeByPerPage($limit, $curr_page); return $this->doData(); }
public function discounts() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } $objectTypes = umiObjectTypesCollection::getInstance(); $type_id = $objectTypes->getBaseType("emarket", "discount"); $limit = getRequest('per_page_limit'); $curr_page = (int) getRequest('p'); $offset = $limit * $curr_page; $sel = new selector('objects'); $sel->types('object-type')->name('emarket', 'discount'); $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); $this->setDataRange($limit, $offset); $data = $this->prepareData($sel->result, "objects"); $this->setData($data, $sel->length); return $this->doData(); }
public function tree() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } $limit = getRequest('per_page_limit'); $curr_page = getRequest('p'); $offset = $curr_page * $limit; $sel = new selector('pages'); $sel->types('hierarchy-type')->name('catalog', 'category'); $sel->types('hierarchy-type')->name('catalog', 'object'); $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); $data = $this->prepareData($sel->result, "pages"); //Завершаем вывод $this->setData($data, $sel->length); $this->setDataRangeByPerPage($limit, $curr_page); return $this->doData(); }
public function view_noactive_comments() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } //Получение id родительской страницы. Если передан неверный id, будет выброшен exception $parent_id = $this->expectElementId('param0'); $limit = 20; $curr_page = (int) getRequest('p'); $offset = $limit * $curr_page; $sel = new selector('pages'); $sel->types('hierarchy-type')->name('comments', 'comment'); $sel->where('is_active')->equals(false); $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); $this->setDataRange($limit, $offset); $data = $this->prepareData($sel->result, "pages"); $this->setData($data, $sel->total); return $this->doData(); }
public function tickets() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } $limit = getRequest('per_page_limit'); $curr_page = getRequest('p'); $offset = $curr_page * $limit; $sel = new selector('objects'); $sel->types('object-type')->name('content', 'ticket'); $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); if (isset($_REQUEST['order_filter']['name'])) { $_REQUEST['order_filter']['message'] = $_REQUEST['order_filter']['name']; unset($_REQUEST['order_filter']['name']); } $data = $this->prepareData($sel->result, "objects"); $this->setData($data, $sel->length); $this->setDataRangeByPerPage($limit, $curr_page); return $this->doData(); }
public function lists() { // Установить формат вывода list // Устанавливаем действие над списокм - "view" - просмотр списка $this->setDataType("list"); $this->setActionType("view"); // если не XmlMode то выдоча того что есть if ($this->ifNotXmlMode()) { return $this->doData(); } // Установить лимит в 20 $limit = 20; /** * Обратите внимание! * Эта строка необходима для корректного определения * текущей страницы Возвращает параметр из $_SERVER['QUERY_STRING'] */ $curr_page = getRequest('p'); // вычисляем смещение от начала списка $offset = $curr_page * $limit; // Установить параметры выборки // Выбирать страницы связанных с методами groupelements и item_element // Установить лимит Смещение от начала списка и количество страниц $sel = new selector('pages'); $sel->types('hierarchy-type')->name('modulelements', 'groupelements'); $sel->types('hierarchy-type')->name('modulelements', 'item_element'); $sel->limit($offset, $limit); // ? Очевидно какой-нибудь фильтр selectorHelper::detectFilters($sel); // Подготавливаем данные, чтобы потом корректно их вывести $data = $this->prepareData($sel->result, "pages"); // Данные, длинна $this->setData($data, $sel->length); $this->setDataRangeByPerPage($limit, $curr_page); return $this->doData(); }
public function onCreateObject($e) { $object = $e->getRef('object'); $objectType = umiObjectTypesCollection::getInstance()->getType($object->getTypeId()); header("Content-type: text/plain"); if ($objectType->getModule() != "dispatches" || $objectType->getMethod() != "subscriber") { return; } if ($e->getMode() == "before") { $sel = new selector('objects'); $sel->types('object-type')->id($objectType->getId()); $sel->where('name')->equals((string) getRequest('name')); $sel->limit(1, 1); if ($sel->first) { umiObjectsCollection::getInstance()->delObject($sel->first->id); $this->errorRegisterFailPage($this->pre_lang . "/admin/dispatches/add/subscriber/"); $this->errorNewMessage(getLabel('error-subscriber-exists'), true); } } }
$reviews->where('lang')->equals(array(1, 2)); //it seems to be the only feasible way to select all languages (FALSE doesn't work) if (!array_key_exists('sort', $_REQUEST)) { $reviews->order('publish_time')->desc(); } else { $sortBy = $_REQUEST['sort']; if (array_key_exists('dir', $_REQUEST) && $_REQUEST['dir'] == 'desc') { $reviews->order($sortBy)->desc(); } else { $reviews->order($sortBy)->asc(); } } $offset = array_key_exists('offset', $_REQUEST) ? $_REQUEST['offset'] : 0; $limit = array_key_exists('limit', $_REQUEST) ? $_REQUEST['limit'] : 0; if ($offset || $limit) { $reviews->limit($offset, $limit); } $res = array(); foreach ($reviews as $review) { $author = umiObjectsCollection::getInstance()->getObject($review->getObject()->author_id); $res[] = array('author_name' => $author->nickname, 'message' => $review->message, 'rating' => $review->rating, 'country' => $review->country, 'language' => $review->language, 'date' => explode('.', $review->publish_time->getFormattedDate('j.n.Y'))); } echo json_encode(array('total' => $reviews->length, 'reviews' => $res)); /* $reviews = new selector('objects'); $reviews->types('object-type')->name('comments', 'comment'); if (!array_key_exists('sort', $_REQUEST)) { $reviews->order('publish_time')->desc(); } else { $sortBy = $_REQUEST['sort'];
/** * Проверяет логин на уникальность * @param string $login - проверяемый логин * @param integer $userId - id редактируемого пользователя * @return boolean true если логин уникален или используется этим пользователем или не задан, false если логин используется другим пользователем */ public function checkIsUniqueLogin($login, $userId = false) { if (!$login) { return true; } $sel = new selector('objects'); $sel->types('object-type')->name('users', 'user'); $sel->where('login')->equals($login); $sel->limit(0, 1); if($sel->first) { return ($userId !== false) ? ($sel->first->id == $userId) : false; } else { return true; } }
public function messages() { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { return $this->doData(); } $limit = getRequest('per_page_limit'); $curr_page = (int) getRequest("p"); $offset = $limit * $curr_page; $sel = new selector('objects'); if ($types = getRequest('object_types')) { $sel->types('object-type')->id($types); } else { $sel->types('object-type')->name('webforms', 'form'); } $sel->limit($offset, $limit); selectorHelper::detectFilters($sel); $this->setDataRange($limit, $offset); $data = $this->prepareData($sel->result, "objects"); $this->setData($data, $sel->length); return $this->doData(); }
public function guide_items_all() { $this->setDataType("list"); $this->setActionType("modify"); if($this->ifNotXmlMode()) return $this->doData(); $per_page = $this->per_page; $guide_id = (int) getRequest('param0'); $sel = new selector('objects'); $sel->types('object-type')->id($guide_id); $maxItemsCount = (int) mainConfiguration::getInstance()->get("kernel", "max-guided-items"); if ($maxItemsCount && $maxItemsCount <= 15 && $maxItemsCount > 0) { $maxItemsCount = 16; } elseif ($maxItemsCount <= 0) { $maxItemsCount = 50; } if ($textSearch = getRequest('search')) { foreach($textSearch as $searchString) $sel->where('name')->like('%' . $searchString . '%'); } if (!permissionsCollection::getInstance()->isSv()) { $sel->where('guid')->notequals('users-users-15'); } if(!is_null(getRequest('limit'))) { $sel->limit((15 * (int) getRequest('p')), 15); } $sel->option('return')->value('count'); $total = $sel->length; if(!is_null(getRequest('allow-empty')) && $total > $maxItemsCount) { $data = Array( 'empty' => Array( 'attribute:total' => $total, 'attribute:result' => 'Too much items' ) ); $this->setDataRange(0, 0); $this->setData($data, $total); return $this->doData(); } else { $sel->flush(); $sel->option('return')->value('id'); $guide_items = array(); $tmp = array(); $objects = umiObjectsCollection::getInstance(); foreach($sel->result as $itemArray) { $itemId = $itemArray['id']; $item = $objects->getObject($itemId); if ($item instanceof umiObject) { $tmp[$itemId] = $item->getName(); $guide_items[$itemId] = $item; } } if(!intval(regedit::getInstance()->getVal("//settings/ignore_guides_sort"))) { natsort($tmp); $guide_items = array_keys($tmp); unset($tmp); } $this->setDataRangeByPerPage($maxItemsCount, 0); $data = $this->prepareData($guide_items, "objects"); $this->setData($data, $total); return $this->doData(); } }
public function listItems($itemType) { $this->setDataType("list"); $this->setActionType("view"); if ($this->ifNotXmlMode()) { $data['nodes:blogs'] = array(array('nodes:blog' => $this->getAllBlogs())); $this->setData($data, 0); return $this->doData(); } $limit = getRequest('per_page_limit'); $curr_page = getRequest('p'); $offset = $limit * $curr_page; $sel = new selector('pages'); $sel->limit($offset, $limit); switch ($itemType) { case 'comment': $sel->types('hierarchy-type')->name('blogs20', 'comment'); break; case 'post': if (!is_null(getRequest('rel'))) { $sel->types('hierarchy-type')->name('blogs20', 'comment'); } $sel->types('hierarchy-type')->name('blogs20', 'post'); break; default: $sel->types('hierarchy-type')->name('blogs20', 'blog'); $sel->types('hierarchy-type')->name('blogs20', 'comment'); $sel->types('hierarchy-type')->name('blogs20', 'post'); } selectorHelper::detectFilters($sel); $this->setDataRange($limit, $offset); $data = $this->prepareData($sel->result, "pages"); $this->setData($data, $sel->length); return $this->doData(); }
public function frontendPanel() { $permissions = permissionsCollection::getInstance(); $cmsController = cmsController::getInstance(); $maxRecentPages = 5; $this->flushAsXml('frontendPanel'); $modules = array(); $modulesSortedPriorityList = $this->getSortedModulesList(); foreach ($modulesSortedPriorityList as $moduleInfo) { $modules[] = array('attribute:label' => $moduleInfo['label'], 'attribute:type' => $moduleInfo['type'], 'node:name' => $moduleInfo['name']); } $hierarchy = umiHierarchy::getInstance(); $key = md5(getServer('HTTP_REFERER')); $currentIds = is_array(getSession($key)) ? getSession($key) : array(); foreach ($currentIds as $i => $id) { $currentIds[$i] = $id[2]; } $currentIds = array_unique($currentIds); $current = array(); foreach ($currentIds as $id) { $current[] = $hierarchy->getElement($id); } $recent = new selector('pages'); $recent->where('is_deleted')->equals(0); $recent->where('is_active')->equals(1); $recent->where('lang')->equals(langsCollection::getInstance()->getList()); $recent->order('updatetime')->desc(); $recent->limit(0, $maxRecentPages); if (sizeof($currentIds) && $permissions->isAllowedModule($permissions->getUserId(), 'backup')) { $backup = $cmsController->getModule('backup'); $changelog = $backup->backup_panel($currentIds[0]); } else { $changelog = null; } $user = selector::get('object')->id($permissions->getUserId()); $referer = getRequest('referer') ? getRequest('referer') : getServer('HTTP_REFERER'); $tickets = new selector('objects'); $tickets->types('object-type')->name('content', 'ticket'); $tickets->where('url')->equals($referer); $tickets->limit(0, 100); $ticketsResult = array(); foreach ($tickets as $ticket) { $user = selector::get('object')->id($ticket->user_id); if (!$user) { continue; } $ticketsResult[] = array('attribute:id' => $ticket->id, 'author' => array('attribute:fname' => $user->fname, 'attribute:lname' => $user->lname, 'attribute:login' => $user->login), 'position' => array('attribute:x' => $ticket->x, 'attribute:y' => $ticket->y, 'attribute:width' => $ticket->width, 'attribute:height' => $ticket->height), 'message' => $ticket->message); } $result = array('user' => array('attribute:id' => $user->id, 'attribute:fname' => $user->fname, 'attribute:lname' => $user->lname, 'attribute:login' => $user->login), 'tickets' => array('nodes:ticket' => $ticketsResult), 'modules' => array('nodes:module' => $modules), 'documents' => array('editable' => array('nodes:page' => $current), 'recent' => array('nodes:page' => $recent->result()))); if (!$permissions->isAllowedMethod($permissions->getUserId(), 'content', 'tickets')) { unset($result['tickets']); } if ($changelog && sizeof($changelog['nodes:revision'])) { $result['changelog'] = $changelog; } $event = new umiEventPoint('eipFrontendPanelGet'); $event->setParam("id", getArrayKey($currentIds, 0)); $event->addRef("result", $result); $event->setMode('after'); $event->call(); return $result; }
public function search_full() { $search_string = (string) getRequest('search_string'); if (!$search_string) { return 'empty'; } $pages = new selector('pages'); $pages->types('hierarchy-type')->name('catalog', 'category'); $pages->where('name')->like('%' . $search_string . '%'); $pages->limit(0, 1); foreach ($pages as $element) { $this->redirect($element->link); } $this->redirect('/search/search_do'); }
public function posted($template = false) { $templater = cmsController::getInstance()->getCurrentTemplater(); $template = $template ? $template : (string) getRequest('template'); $template = $template ? $template : (string) getRequest('param0'); $res = false; if ($template && is_numeric($template)) { $sel = new selector('objects'); $sel->types('object-type')->name('webforms', 'template'); $sel->where('form_id')->equals($template); $sel->limit(0, 1); if ($sel->result) { $oTemplate = $sel->result[0]; $res = $oTemplate->getValue('posted_message'); } if (!$res && !def_module::isXSLTResultMode()) { try { list($template) = $this->loadTemplates("./tpls/webforms/" . $template, "posted"); $res = $template; } catch (publicException $e) { } } } if (!$res) { if (defined('CURRENT_VERSION_LINE') && CURRENT_VERSION_LINE == 'demo') { $res = "%webforms_thank_you_demo%"; } else { $res = "%webforms_thank_you%"; } } return $templater->putLangs($res); }
public function getGuideItems($template = "default", $guide_id = false, $per_page = 100, $curr_page = 0) { if (!$curr_page) { $curr_page = (int) getRequest('p'); } if (!$guide_id) { $guide_id = (int) getRequest('param0'); } if (!$template) { $template = "default"; } list($template_block, $template_block_empty, $template_line) = def_module::loadTemplates("data/" . $template, "guide_block", "guide_block_empty", "guide_block_line"); $sel = new selector('objects'); $sel->types('object-type')->id($guide_id); $sel->limit($per_page * $curr_page, $per_page); selectorHelper::detectFilters($sel); $block_arr = array(); $lines = array(); foreach ($sel->result as $element) { $line_arr = array(); $line_arr['attribute:id'] = $element->getId(); $line_arr['xlink:href'] = "uobject://" . $element->getId(); $line_arr['node:text'] = $element->getName(); $lines[] = self::parseTemplate($template_line, $line_arr); } $block_arr['attribute:guide_id'] = $guide_id; $block_arr['subnodes:items'] = $lines; $block_arr['total'] = $sel->total; return self::parseTemplate($template_block, $block_arr); }
public function restore($activate_code = false, $template = "default") { static $result = array(); if (isset($result[$template])) { return $result[$template]; } list($template_restore_failed_block, $template_restore_ok_block, $template_mail_password, $template_mail_password_subject) = def_module::loadTemplatesForMail("users/forget/" . $template, "restore_failed_block", "restore_ok_block", "mail_password", "mail_password_subject"); if (!$activate_code) { $activate_code = (string) getRequest('param0'); $activate_code = trim($activate_code); } $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("users", "user"); $object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id); $activate_code_field_id = $object_type->getFieldId("activate_code"); $sel = new selector('objects'); $sel->types('object-type')->name('users', 'user'); $sel->where('activate_code')->equals($activate_code); $sel->limit(0, 1); if ($sel->first) { $object = $sel->first; $user_id = $object->id; } else { $object = false; $user_id = false; } $block_arr = array(); if ($user_id && $activate_code) { $password = self::getRandomPassword(); $login = $object->getValue("login"); $email = $object->getValue("e-mail"); $fio = $object->getValue("lname") . " " . $object->getValue("fname") . " " . $object->getValue("father_name"); $object->setValue("password", md5($password)); $object->setValue("activate_code", ""); $object->commit(); $email_from = regedit::getInstance()->getVal("//settings/email_from"); $fio_from = regedit::getInstance()->getVal("//settings/fio_from"); $mail_arr = array(); $mail_arr['domain'] = $domain = $_SERVER['HTTP_HOST']; $mail_arr['password'] = $password; $mail_arr['login'] = $login; $mail_subject = def_module::parseTemplateForMail($template_mail_password_subject, $mail_arr, false, $user_id); $mail_content = def_module::parseTemplateForMail($template_mail_password, $mail_arr, false, $user_id); $someMail = new umiMail(); $someMail->addRecipient($email, $fio); $someMail->setFrom($email_from, $fio_from); $someMail->setSubject($mail_subject); $someMail->setContent($mail_content); $someMail->commit(); $someMail->send(); $block_arr['attribute:status'] = "success"; $block_arr['login'] = $login; $block_arr['password'] = $password; return $result[$template] = def_module::parseTemplate($template_restore_ok_block, $block_arr, false, $user_id); } else { $block_arr['attribute:status'] = "fail"; return $result[$template] = def_module::parseTemplate($template_restore_failed_block, $block_arr); } }
public function leaders_list() { $pages = new selector('pages'); $pages->types('hierarchy-type')->name('catalog', 'object'); $pages->where('bestseller')->equals('1'); $pages->limit(0, 6); $res = ''; foreach ($pages as $page) { $res .= ' <div class="item"> <a href="' . "{$page->link}" . '"> <img src="' . "{$page->pic1}" . '" alt="' . "{$page->name}" . '" /> <span><b>' . "{$page->name}" . '</b></span> </a> </div> '; } return $res; }
public function getPermissionsOwners() { $this->flushAsXML('getPermissionsOwners'); $buffer = outputBuffer::current(); $objects = umiObjectsCollection::getInstance(); $objectTypes = umiObjectTypesCollection::getInstance(); $groupTypeId = $objectTypes->getBaseType('users', 'users'); $svGroupId = $objects->getObjectIdByGUID('users-users-15'); $svId = $objects->getObjectIdByGUID('system-supervisor'); $restrict = array($svId, $svGroupId); $sel = new selector('objects'); $sel->types('object-type')->name('users', 'users'); $sel->types('object-type')->name('users', 'user'); $sel->limit(0, 15); selectorHelper::detectFilters($sel); $items = array(); foreach ($sel as $object) { if (in_array($object->id, $restrict)) { continue; } $usersList = array(); if ($object->getTypeId() == $groupTypeId) { $users = new selector('objects'); $users->types('object-type')->name('users', 'user'); $users->where('groups')->equals($object->id); $users->limit(0, 5); foreach ($users as $user) { $usersList[] = array('attribute:id' => $user->id, 'attribute:name' => $user->name, 'xlink:href' => $user->xlink); } $type = 'group'; } else { $type = 'user'; } $items[] = array('attribute:id' => $object->id, 'attribute:name' => $object->name, 'attribute:type' => $type, 'xlink:href' => $object->xlink, 'nodes:user' => $usersList); } return array('list' => array('nodes:owner' => $items)); }