/** * Displays backend navigation menu * * @param array $params * @param Smarty $smarty * @return string * * @package application.helper.smarty * @author Integry Systems */ function smarty_function_backendMenu($params, Smarty_Internal_Template $smarty) { $smarty = $smarty->smarty; $locale = $smarty->getApplication()->getLocale(); $request = $smarty->getApplication()->getRequest(); $controller = $request->get('controller'); $action = $request->get('action'); // load language file for menu $locale->translationManager()->loadFile('backend/menu'); $menuLoader = new MenuLoader($smarty->getApplication(), $params['menu']); $structure = $menuLoader->getCurrentHierarchy($controller, $action); $router = $smarty->getApplication()->getRouter(); // get translations and generate URL's $items = array(); foreach ($structure['items'] as $topValue) { if (!empty($topValue['role']) && !AccessStringParser::run($topValue['role'])) { continue; } $filteredValue = array(); foreach (array('title', 'descr') as $field) { $filteredValue[$field] = $smarty->branding($locale->translator()->translate($topValue[$field])); } $filteredValue['controller'] = isset($topValue['controller']) ? $topValue['controller'] : ''; $filteredValue['action'] = isset($topValue['action']) ? $topValue['action'] : ''; $filteredValue['icon'] = isset($topValue['icon']) ? $topValue['icon'] : ''; if (!empty($topValue['controller'])) { $filteredValue['url'] = $router->createUrl(array('controller' => $topValue['controller'], 'action' => isset($topValue['action']) ? $topValue['action'] : null), true); } if (isset($topValue['items']) && is_array($topValue['items'])) { $subItems = array(); foreach ($topValue['items'] as &$subValue) { if (!empty($subValue['role']) && !AccessStringParser::run($subValue['role'])) { continue; } $filteredSubValue = array(); foreach (array('title', 'descr') as $field) { $filteredSubValue[$field] = $smarty->branding($locale->translator()->translate($subValue[$field])); } $filteredSubValue['url'] = $router->createUrl(array('controller' => $subValue['controller'], 'action' => isset($subValue['action']) ? $subValue['action'] : null), true); if (!empty($subValue['query'])) { $filteredSubValue['url'] .= '?' . $subValue['query']; } $filteredSubValue['controller'] = $subValue['controller']; $filteredSubValue['action'] = isset($subValue['action']) ? $subValue['action'] : ''; $filteredSubValue['icon'] = isset($subValue['icon']) ? $subValue['icon'] : ''; $subItems[] = $filteredSubValue; } if (count($subItems) > 0) { $filteredValue['items'] = $subItems; } } $items[] = $filteredValue; } $smarty->assign('menuArray', json_encode($items)); $smarty->assign('controller', $controller); $smarty->assign('action', $action); return $smarty->display('block/backend/backendMenu.tpl'); }
public static function isGuest() { if (!self::$_usr) { self::$_usr = FrontuserHelper::getLoginUser(); } if (self::$_usr) { return false; } else { return true; } }
<div id="logo" style="line-height:70px;"><?php echo CHtml::encode(Yii::app()->name); ?> <div style="float: right;"> <img src="<?php echo Yii::app()->request->baseUrl; ?> /images/logo.jpg" alt="" /> </div> <div style="clear: both;"></div> </div> </div><!-- header --> <div id="mainmenu"> <?php $this->widget('zii.widgets.CMenu', array('items' => MenuLoader::getMainMenu())); ?> </div><!-- mainmenu --> <?php if (isset($this->breadcrumbs)) { ?> <?php $this->widget('zii.widgets.CBreadcrumbs', array('links' => $this->breadcrumbs)); ?> <!-- breadcrumbs --> <?php } ?> <?php echo $content;
addToList(data); return false; }); $('#mission-box').delegate('.pager-item','click',function(){ var page = $(this).attr('data-page'); getList(page); return false; }); $('#selected-box').delegate('.unselect-link','click',function(){ var data = $(this).attr('data-content'); delFromList(data); return false; }); $('#submit_mission').click(function(){ <?php if (MenuLoader::isGuest()) { ?> alert("You can't submit search task without login."); location.href="<?php echo Yii::app()->createUrl('site/login'); ?> "; <?php } else { ?> var data = {}; data.items = compare_data; data.start = $('select[name="temporalStart"]').val(); data.end = $('select[name="temporalEnd"]').val(); data.latMin = $('input[name="latMin"]').val(); data.latMax = $('input[name="latMax"]').val();
public function index() { Role::cleanUp(); $userGroupID = (int) $this->request->get('id'); $userGroup = UserGroup::getInstanceByID($userGroupID); $activeRoles = $userGroup->getRolesRecordSet(); $roles = array(); $parentID = 0; // sort roles by their appearance in backend menu $filter = new ARSelectFilter(); foreach (array('product', 'category', 'option', 'filter', 'order', 'user') as $roleName) { $filter->setOrder(new ARExpressionHandle('(Role.name LIKE "' . $roleName . '%")'), 'DESC'); } // disabled roles $disable = ClassLoader::getRealPath('storage.configuration.DisabledRoles') . '.php'; if (file_exists($disable)) { $disabledRoles = (include $disable); foreach ($disabledRoles as $disabled) { $filter->mergeCondition(new NotEqualsCond(new ARFieldHandle('Role', 'name'), $disabled)); } } $menu = new MenuLoader($this->application); $menuItems = $menu->getCurrentHierarchy('', ''); //print_r($menuItems); $menuItems = $menuItems['items']; foreach ($menuItems as $topLevel) { if (isset($topLevel['items'])) { foreach ($topLevel['items'] as $item) { if (isset($item['role'])) { $filter->setOrder(new ARExpressionHandle('(Role.name LIKE "' . $item['role'] . '%")'), 'DESC'); } } } } foreach (Role::getRecordSet($filter) as $role) { $roleArray = $role->toArray(); if ('login' == $roleArray['name']) { continue; } $roleArray['indent'] = strpos($roleArray['name'], '.') ? 1 : 0; if ($roleArray['indent'] > 0) { $rc = count($roles) - 1; if (isset($roles[$rc]) && $roles[$rc]['parent'] === 0) { $parentID = 'smart-' . $roles[$rc]['ID']; $roles[] = array('ID' => $roles[$rc]['ID'], 'name' => $roles[$rc]['name'] . '.misc', 'translation' => $this->translate('_role_' . strtolower($roles[$rc]['name']) . '_misc'), 'parent' => $parentID, 'indent' => 1); $roles[$rc]['ID'] = $parentID; } $roleArray['parent'] = $parentID; } else { $parentID = $roleArray['ID']; $roleArray['parent'] = 0; } $roleArray['translation'] = $this->translate(strtolower("_role_" . str_replace('.', '_', $roleArray['name']))); $roles[] = $roleArray; } $activeRolesIDs = array(); foreach ($activeRoles as $role) { $activeRolesIDs[] = $role->getID(); } $form = $this->createRolesForm($userGroup, $activeRoles); $response = new ActionResponse(); $response->set('form', $form); $response->set('roles', $roles); $response->set('userGroup', $userGroup->toArray()); $response->set('activeRolesIDs', $activeRolesIDs); return $response; }
public function actionAjaxGetStatus() { $task_idstr = Yii::app()->request->getParam('tasks'); $user_id = MenuLoader::getUserId(); $ids = explode(',', $task_idstr); foreach ($ids as $k => &$v) { $v = '"' . trim($v) . '"'; } $idstr = implode(',', $ids); $my_tasks = array(); $tasks_proccess = array(); if ($idstr) { //Yii::log('task ids:'.$idstr, 'info'); $criteria = new CDbCriteria(); $criteria->condition = 'task_id IN (' . $idstr . ') AND user_id=:user_id'; $criteria->params = array(':user_id' => $user_id); $my_tasks = UserTask::model()->findAll($criteria); $base_url = TSInterface::get('G3'); foreach ($my_tasks as &$task) { //Yii::log('task id:'.$task->id.' status:'.$task->status, 'info'); if ($task->status != 0 && $task->status != 1) { continue; } $tasks_proccess[$task->id] = array('total' => 0, 'failed' => 0, 'running' => 0, 'finished' => 0); $url = $base_url . '?taskId=' . $task->task_id; $content = NetHelper::curl_file_get_contents($url); Yii::log('TASK_' . $task->task_id . ' URL:' . $url . ' return:' . $content, 'info'); $data = json_decode($content, true); if ($data && $data['success']) { $all_status = 'finished'; if (empty($data['data'])) { $all_status = 'running'; } foreach ($data['data'] as $item) { $tasks_proccess[$task->id]['total']++; if ($item['status'] == 'failed') { $all_status = 'failed'; $tasks_proccess[$task->id]['failed']++; break; } if ($item['status'] == 'running') { $all_status = 'running'; $tasks_proccess[$task->id]['running']++; break; } if ($item['status'] == 'finished') { $tasks_proccess[$task->id]['finished']++; //break; } } if ($all_status == 'running') { $task->status = 1; } if ($all_status == 'failed') { $task->status = -1; } if ($all_status == 'finished') { $task->status = 2; } $task->save(); $updateArr = array('status' => $task->status); if ($task->status == 2 || $task->status == -1) { $updateArr['task_result'] = $content; $updateArr['finish_time'] = time(); } Yii::log('UPDATE TASK_' . $task->id . ' update_info:' . json_encode($updateArr), 'info'); Task::model()->updateAll($updateArr, 'task_id=:task_id', array(':task_id' => $task->task_id)); } } } $retArr = array(); foreach ($my_tasks as $item) { //Yii::log('export task id:'.$item->id.' status:'.$item->status, 'info'); $retArr[$item->id] = $item->status; } echo json_encode($retArr); }