public function RenderFileBrowser($parentId, $depth = 1, $level = 0, $basePath = null, $id = 'fileTree')
 {
     // @todo: deal with selected menu items
     if ($level <= $depth - 1) {
         $links = array();
         $menu = new Model_Menu();
         $children = $menu->getMenuItems($parentId);
         foreach ($children as $child) {
             if (!empty($child->label)) {
                 $label = $child->label;
             } else {
                 $label = $child->title;
             }
             $children = $menu->getMenuItems($child->id);
             if ($children->count() > 0) {
                 $class = 'dir';
                 $newLevel = $level + 1;
                 $submenu = $this->view->RenderFileBrowser($child->id, $depth, $newLevel, $link);
             } else {
                 $class = 'page';
                 $submenu = false;
             }
             $linkId = Digitalus_Toolbox_String::addUnderscores($menu->path, true);
             $links[] = "<li class='menuItem'><a href='/admin/page/open/id/{$child->id}' class='{$class}' id='page-{$child->id}'>{$label}</a>" . $submenu . '</li>';
         }
     }
     if (is_array($links)) {
         if ($level == 0) {
             $strId = "id='{$id}'";
         }
         return "<ul {$strId}>" . implode(null, $links) . '</ul>';
     }
 }
 public function updateAction()
 {
     $id = $this->_request->getParam('id');
     // fetch the current item
     $mdlMenuItem = new Model_MenuItem();
     $currentMenuItem = $mdlMenuItem->find($id)->current();
     // fetch its menu
     $mdlMenu = new Model_Menu();
     $this->view->menu = $mdlMenu->find($currentMenuItem->menu_id)->current();
     // create and populate the form instance
     $frmMenuItem = new Form_MenuItem();
     $frmMenuItem->setAction('/menuitem/update');
     // process the postback
     if ($this->_request->isPost()) {
         if ($frmMenuItem->isValid($_POST)) {
             $data = $frmMenuItem->getValues();
             $mdlMenuItem->updateItem($data['id'], $data['label'], $data['page_id'], $data['link']);
             $this->_request->setParam('menu', $data['menu_id']);
             return $this->_forward('index');
         }
     } else {
         $frmMenuItem->populate($currentMenuItem->toArray());
     }
     $this->view->form = $frmMenuItem;
 }
Example #3
0
 public function deleteAction()
 {
     $id = $this->_request->getParam('id');
     $mdlMenu = new Model_Menu();
     $mdlMenu->deleteMenu($id);
     $this->_forward('index');
 }
Example #4
0
File: Base.php Project: pancke/yyaf
     if ($this->bCheckLogin) {
         // 当前用户
         $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie'));
         if (empty($aCookie)) {
             return $this->redirect('/admin/login');
         }
         $this->aCurrUser = $aCookie;
         // 当前城市
         $this->iCurrCityID = Util_Cookie::get('city');
         if (empty($this->iCurrCityID)) {
             $this->iCurrCityID = $this->aCurrUser['iCityID'];
         }
         $this->aCurrCity = Model_City::getDetail($this->iCurrCityID);
     }
     $this->assign('sStaticRoot', 'http://' . Yaf_G::getConf('static', 'domain'));
 }
 /**
  * 执行Action后的操作
  * 
  * @see Yaf_Controller::actionAfter()
  */
 public function actionAfter()
 {
     if ($this->autoRender() == true) {
         if (!empty($this->aCurrUser)) {
             $this->assign('aCurrUser', $this->aCurrUser);
Example #5
0
 /**
  *
  * @return <type>
  */
 public function pages($pModule)
 {
     $pages = array();
     $req = Zend_Controller_front::getInstance()->getRequest();
     $active_module = $req->getModuleName();
     $active_controller = $req->getControllerName();
     $sql = array('(required = 1) OR (active = 1)', 'sort_by');
     $modules = Administer_Model_Modules::getInstance()->find_from_sql($sql, TRUE, FALSE);
     foreach ($modules as $module) {
         $module->menu();
         $module_names[] = '"' . $module->folder . '"';
     }
     $module_is_active = sprintf(' (module = "%s") ', $active_module);
     $mm = Model_Menu::getInstance();
     $sql = sprintf('(module in (%s)) AND (parent = 0)', join(',', $module_names));
     //// at this point have selected all the menus of this module
     $sql .= sprintf(' AND ((if_module = 0) OR (%s)) ', $module_is_active);
     // if the menu only viewable in the context of the current menu,
     // require the module to be current
     error_log(__METHOD__ . ': menu sql = ' . $sql);
     foreach ($mm->find_from_sql(array($sql, array('sort_by', 'label'))) as $menu) {
         $new_pages = $menu->pages();
         $pages = array_merge($pages, $new_pages);
     }
     return new Zend_Navigation($pages);
 }
Example #6
0
File: Menu.php Project: Gorp/pr
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #7
0
 public function indexAction()
 {
     $aMenus = Model_Menu::getMenus();
     $this->assign('aData', $aMenus);
     $this->_frame = 'frame.phtml';
     //return $this->redirect($sUrl);
 }
Example #8
0
 /**
  *
  * @param boolean $pReload
  * @return Model_Menu
  */
 static function getInstance($pReload = FALSE)
 {
     if ($pReload || is_null(self::$_Instance)) {
         // process
         self::$_Instance = new self(Zupal_Domain_Abstract::STUB);
     }
     return self::$_Instance;
 }
Example #9
0
 public function RenderMenuBrowser($parentId, $basePath = null, $id = 'menuTree')
 {
     $menu = new Model_Menu();
     $children = $menu->getMenuItems($parentId, true);
     foreach ($children as $child) {
         $label = $child->title;
         if (!empty($child->label)) {
             $label = $child->label . ' / ' . $label;
         }
         $class = 'menu';
         $submenu = $this->view->RenderMenuBrowser($child->id, $link);
         $linkId = Digitalus_Toolbox_String::addUnderscores($menu->path, true);
         $links[] = "<li class='menuItem'><a href='/admin/navigation/open/id/{$child->id}' class='{$class}' id='page-{$child->id}'>{$label}</a>" . $submenu . '</li>';
     }
     if (is_array($links)) {
         if ($level == 0) {
             $strId = "id='{$id}'";
         }
         return "<ul {$strId}>" . implode(null, $links) . '</ul>';
     }
 }
 public function renderMenuBrowser($parentId, $basePath = null, $id = 'menuTree')
 {
     $menu = new Model_Menu();
     $children = $menu->getMenuItems($parentId, true);
     foreach ($children as $child) {
         $label = $child->title;
         if (!empty($child->label)) {
             $label = $child->label . ' / ' . $label;
         }
         $class = 'menu';
         $submenu = $this->view->renderMenuBrowser($child->id, $link);
         $linkId = Digitalus_Toolbox_String::addUnderscores($menu->path, true);
         $links[] = '<li class="menuItem"><a href="/admin/navigation/open/id/' . $child->id . '" class="' . $class . '" id="page-' . $child->id . '">' . $label . '</a>' . $submenu . '</li>';
     }
     if (is_array($links)) {
         if ($level == 0) {
             $strId = 'id="' . $id . '"';
         }
         return '<ul ' . $strId . '>' . implode(null, $links) . '</ul>';
     }
 }
Example #11
0
 /**
  * this function loads the current menu and is run automatically by the constructor
  *
  */
 protected function _load()
 {
     $cache = Zend_Registry::get('cache');
     $children = $cache->load(self::CACHE_ID);
     $mdlMenu = new Model_Menu();
     if ($children === false) {
         $children = $mdlMenu->getChildren($this->_parentId);
         $cache->save($children, self::CACHE_ID);
     }
     if ($children != null && $children->count() > 0) {
         foreach ($children as $child) {
             $this->pages[] = new Digitalus_Menu_Item(null, $child);
         }
         $container = new Zend_Navigation($this->pages);
         // set container, acl and role for view helper
         $acl = new Digitalus_Acl();
         $this->view->navigation($container);
         $this->view->navigation()->setAcl($acl);
         $this->view->navigation()->setRole($this->_identity->role);
     }
     // write Zend_Navigation into registry
     Zend_Registry::set('Zend_Navigation', $container);
 }
Example #12
0
File: Role.php Project: pancke/yyaf
 /**
  * 增加角色
  * @return NULL|boolean
  */
 public function addAction()
 {
     if ($this->isPost()) {
         $aRole = $this->_checkData();
         if (empty($aRole)) {
             return null;
         }
         if (Model_Role::addData($aRole) > 0) {
             return $this->showMsg('角色增加成功!', true);
         } else {
             return $this->showMsg('角色增加失败!', false);
         }
     } else {
         $this->assign('aPermissionList', Model_Permission::getAllPermissions());
         $this->assign('aMenuList', Model_Menu::getMenus());
     }
 }
Example #13
0
 public function permissionAction()
 {
     $aMenuList = Model_Menu::getMenus();
     $aCtrClass = array();
     $aMenuAction = array();
     foreach ($aMenuList as $aMenu) {
         if ($aMenu['bIsLeaf']) {
             $aRoute = Yaf_G::getRoute($aMenu['sUrl']);
             $aMenuAction[$aRoute['module'] . '_' . $aRoute['controller'] . '_' . $aRoute['action']] = $aMenu['sMenuName'];
             $aCtrClass[$aRoute['module'] . '_' . $aRoute['controller']] = array('iMenuID' => $aMenu['iMenuID'], 'sMenuName' => $aMenu['sMenuName'], 'sUrl' => $aMenu['sUrl']);
         }
     }
     $aPermission = array();
     foreach ($aCtrClass as $sCtrClass => $aMenu) {
         try {
             $sCtrClass = 'Controller_' . $sCtrClass;
             if (class_exists($sCtrClass)) {
                 $oCtr = new ReflectionClass($sCtrClass);
                 $aMethod = $oCtr->getMethods();
                 foreach ($aMethod as $oMethod) {
                     $sAction = $oMethod->getName();
                     if (substr($sAction, -6) === 'Action') {
                         $sAction = substr($sAction, 0, -6);
                         $aRow = array($aMenu['iMenuID']);
                         $aRow[] = Yaf_G::routeToUrl($sCtrClass . '_' . $sAction);
                         $sDoc = $oMethod->getDocComment();
                         $matches = null;
                         if (preg_match('/\\s+\\*\\s+(.+)/i', $sDoc, $matches)) {
                             $aRow[] = $matches[1];
                         } elseif (isset($aMenuAction[$sCtrClass . '_' . $sAction])) {
                             $aRow[] = $aMenuAction[$sCtrClass . '_' . $sAction];
                         } else {
                             $aRow[] = $aMenu['sMenuName'] . '::' . $sAction;
                         }
                         $aPermission[] = $aRow;
                     }
                 }
             }
         } catch (Exception $e) {
             $aPermission[] = array($aMenu['iMenuID'], Yaf_G::getUrl($aMenu['sUrl']), $aMenu['sMenuName']);
         }
     }
     $this->showMsg($aPermission, true);
 }
Example #14
0
 /**
  *
  * @return void
  */
 public function _parent_menu($panel, $parent = NULL, $pDepth = 0)
 {
     $out = array();
     if ($parent) {
         $mt = new Model_Menu($parent);
         $found = $mt->children();
     } else {
         $mt = Model_Menu::getInstance();
         $params = array('parent' => 0, 'panel' => $panel);
         $found = $mt->find($params, 'sort_by');
     }
     foreach ($found as $m) {
         $out[$m->identity() . '_' . $panel] = $this->_pm_prefix($pDepth) . $m->label;
         foreach ($this->_parent_menu($panel, $m->identity(), $pDepth + 1) as $k => $v) {
             $out[$k] = $v;
         }
     }
     return $out;
 }
 /**
  * Edit action
  *
  * Edit a menu
  *
  * @return void
  */
 public function editAction()
 {
     if ($this->_request->isPost()) {
         $m = new Model_Menu();
         $ids = Digitalus_Filter_Post::raw('id');
         $labels = Digitalus_Filter_Post::raw('label');
         $visibility = Digitalus_Filter_Post::raw('show_on_menu');
         $m->updateMenuItems($ids, $labels, $visibility);
         $menuId = Digitalus_Filter_Post::get('menuId');
         $url = 'admin/navigation/open/id/' . $menuId;
         $this->_redirect($url);
     }
 }
Example #16
0
 /**
  * Get Page data as array
  *
  * @return  array  Returns an array of the page data, otherwise an empty array
  */
 protected function _getPageAsArray($item = null)
 {
     if (empty($item)) {
         $item = $this->getItem();
     }
     $baseUrl = $this->view->baseUrl();
     $mdlMenu = new Model_Menu();
     $page = array('active' => $this->isActive(false), 'class' => 'menuItem', 'id' => $item->id, 'label' => Digitalus_Toolbox_Page::getLabel($item), 'name' => $item->name, 'resource' => strtolower(Digitalus_Toolbox_String::replaceEmptySpace($item->name)), 'title' => Digitalus_Toolbox_Page::getLabel($item), 'uri' => $baseUrl . '/' . Digitalus_Toolbox_String::replaceEmptySpace(Digitalus_Toolbox_Page::getUrl($item)), 'visible' => $this->isVisible($item));
     $subPages = array();
     if ($mdlMenu->hasChildren($this->id)) {
         $children = $mdlMenu->getChildren($this->id);
         foreach ($children as $child) {
             $subPages[] = new Digitalus_Menu_Item(null, $child);
         }
         $page['pages'] = $subPages;
     }
     return $page;
 }
Example #17
0
 public function ussdProgress($user, $message)
 {
     $menu_item_id = $user->menu_item_id;
     // print_r($menu_item_id);
     // exit;
     $step = $user->step;
     $menuModel = new Model_Menu();
     $menu = $menuModel->getMenu($menu_item_id);
     // print_r($menu);
     // exit;
     if ($menu['id'] == 0) {
         $reply = "We could not understand your response";
         $output = $this->mainMenu($user, $user['phoneno']);
         return $reply . PHP_EOL . $output;
     }
     //
     $menuType = $menu->type;
     // print_r($menuType);
     // exit;
     // print_r($step);
     // exit;
     if ($menuType == 2) {
         //no verification but feed it response and update step as you move on
         if ($step > 0) {
             $message = strtolower($message);
             //feed the response to the table
             // print_r($message);
             // exit;
             $valid = 1;
             $valid = $this->validateResponse($menu->id, $message, $step);
             // print_r($valid);
             // exit;
             if (is_array($valid) && $valid['valid'] == 0) {
                 $output = $valid['message'];
                 //print_r($output);
                 return $output;
             }
             $dataa = array('user_id' => $user['id'], 'menu_id' => $menu_item_id, 'step' => $step, 'response' => $message);
             //print_r($dataa);
             //exit;
             $Response_Model = new Model_Response();
             $result = $Response_Model->createResponse($dataa);
             // print_r($result);
             // exit;
             if ($result) {
                 //check if we have another step, if we do, request, if we dont, compile the summary and confirm
                 $next_step = $step + 1;
                 // print_r($step);
                 // exit;
                 $menuItemsModel = new Model_MenuItems();
                 $menuItem = $menuItemsModel->getNextMenuStep($menu_item_id, $next_step);
                 // print_r($menuItem);
                 // exit;
                 if ($menuItem['id'] != 0) {
                     //update user data and next request and send back
                     $userModel = new Model_User();
                     $result = $userModel->updateUserMenuStep($user['id'], $next_step);
                     //$menuItem = $menuItemsModel -> getNextMenuStep($menu_item_id,$step);
                     return $menuItem->description;
                     //exit;
                 } else {
                     //compile summary for confirmation
                     //$menuItemsModel = new Model_MenuItems();
                     $MenuItems = $menuItemsModel->getMenuItems($menu_item_id);
                     //print_r($MenuItems);
                     //exit;
                     //build up the responses
                     $confirmation = "Confirm?: " . $menu->description;
                     foreach ($MenuItems as $key => $value) {
                         // print_r($value);
                         // exit;
                         //print_r($confirmation);
                         //exit;
                         //select the corresponding response
                         if ($value[4] != 'PIN') {
                             $phrase = $value[4];
                             //print_r($value[4]);
                             //$menu_item_id = $value['']
                             $response = $Response_Model->getResponse($user['id'], $menu_item_id, $value[3]);
                             //print_r($response['response']."<br>");
                             if ($value[4] == 'Gender') {
                                 if ($response['response'] == 1) {
                                     $response['response'] = 'Male';
                                 } elseif ($response['response'] == 2) {
                                     $response['response'] = 'Female';
                                 }
                             } elseif ($value[4] == 'Language') {
                                 if ($response['response'] == 1) {
                                     $response['response'] = 'English';
                                 } elseif ($response['response'] == 2) {
                                     $response['response'] = 'Kiswahili';
                                 }
                             } elseif ($value[4] == 'Card') {
                                 if ($response['response'] == 1) {
                                     $response['response'] = 'Bebapay';
                                 } elseif ($response['response'] == 2) {
                                     $response['response'] = 'Abiria';
                                 } elseif ($response['response'] == 3) {
                                     $response['response'] = '1963';
                                 }
                             }
                             $confirmation = $confirmation . PHP_EOL . $value[4] . ": " . $response['response'];
                             //print_r($response['response']);
                             //exit;
                         }
                     }
                     // print_r($confirmation);
                     // exit;
                     //update the status to waiting for confirmation
                     $userModel = new Model_User();
                     $data = array('session' => 2, 'confirm_from' => $menu->id);
                     //print_r($user['id']);
                     //exit;
                     $result = $userModel->updateUserData($data, $user['id']);
                     //print_r($result);
                     //exit;
                     //$result = $userModel -> updateUserSession($user['id'],2);
                     return $confirmation . PHP_EOL . "1. Yes" . PHP_EOL . "2. No";
                     //exit;
                 }
                 //print_r($menuItem);
                 //exit;
             }
         } else {
             //when the user has not started the steps
             $userModel = new Model_User();
             $result = $userModel->updateUserMenuStep($user['id'], 1);
             $menuItemsModel = new Model_MenuItems();
             $menuItem = $menuItemsModel->getNextMenuStep($menu_item_id, 1);
             return $menuItem->description;
             //exit;
         }
     } else {
         //verify response
         $menuItemsModel = new Model_MenuItems();
         $MenuItems = $menuItemsModel->getMenuItems($menu_item_id);
         //now we have the menu items it is time to create the USSD Menu
         // print_r($message);
         // exit;
         if (empty($MenuItems)) {
             $selected_option = $message;
         } else {
             // echo "hapa";
             // exit;
             $message = strtolower($message);
             // print_r($message);
             // exit;
             foreach ($MenuItems as $key => $value) {
                 //check if they are equal
                 // print_r($value);
                 // exit;
                 if (trim(strtolower($key)) == $message) {
                     //foreach ($value as $key1 => $value1) {
                     $selected_option = $key;
                     $next_menu_id = $value[2];
                     //check for the type of menu_item_id
                     if ($value[5] == 3) {
                         //survey
                         $output = $this->takeSurvey($user, $message);
                         return $output;
                     }
                 }
                 if (empty($selected_option)) {
                     foreach ($value as $key1 => $value1) {
                         //print_r($value1);
                         //exit;
                         if (trim(strtolower($value1)) == $message) {
                             $selected_option = $value1;
                         }
                     }
                 }
             }
         }
         // print_r($selected_option);
         // exit;
         //
         if (empty($selected_option)) {
             $selected_option = 0;
         }
         if (empty($next_menu_id)) {
             $next_menu_id = 0;
         }
         //update the progress with the next menu id
         $userModel = new Model_User();
         $no = $user['phoneno'];
         $result = $userModel->updateUser($next_menu_id, $no);
         if ($result) {
             $menuModel = new Model_Menu();
             $reply = "";
             //print_r($user);
             //exit;
             if ($next_menu_id == 0) {
                 //if ($menu['id'] == 0) {
                 $reply = "We could not understand your response";
                 $next_menu_id = $user['menu_item_id'];
                 //$output = $this->mainMenu($user, $user['phoneno']);
                 //return $reply.PHP_EOL.$output;
                 //}
             }
             //print_r($next_menu_id);
             //exit;
             $menu = $menuModel->getMenu($next_menu_id);
             //print_r($menu);
             //exit;
             $menu_id = $menu['id'];
             $menuType = $menu['type'];
             // print_r($step);
             // exit;
             if ($menuType == 2) {
                 //$menu
                 // print_r($menu);
                 // exit;
                 $output = $this->singleProcess($menu_id, $user);
                 //$output = $this->singleProcess($menu_item_id);
                 return $output;
             } else {
                 //get the description
                 $description = $menu->description;
                 //build up the options
                 $menuItemsModel = new Model_MenuItems();
                 $menuOptions = $menuItemsModel->getMenuOptions($menu_id);
                 return $description . PHP_EOL . $menuOptions;
                 //exit;
             }
         }
     }
 }
 /**
  *
  * @param Model_Menu $pMenu
  * @return array
  */
 public function _menu_ini(Model_Menu $pMenu)
 {
     $out = $pMenu->toArray();
     unset($out['parent']);
     unset($out['id']);
     unset($out['path']);
     foreach (array('href', 'callback_class', 'parameters') as $param) {
         if (!$out[$param]) {
             unset($out[$param]);
         }
     }
     foreach ($pMenu->children() as $i => $child) {
         $data = $this->_menu_ini($child);
         $data['sort_by'] = $i + 1;
         $out['pages'][$child->name] = $data;
     }
     return $out;
 }
Example #19
0
File: Menu.php Project: pancke/yyaf
 /**
  * 增加菜单
  */
 public function addAction()
 {
     if ($this->isPost()) {
         $aMenu = $this->_checkData();
         if (empty($aMenu)) {
             return null;
         }
         $aMenu['iOrder'] = Model_Menu::getNextOrder($aMenu['iParentID']);
         if (Model_Menu::addData($aMenu) > 0) {
             return $this->showMsg('菜单增加成功!', true);
         } else {
             return $this->showMsg('菜单增加失败!', false);
         }
     } else {
         $aTree = Model_Menu::getMenus();
         $this->assign('aTree', $aTree);
     }
 }
Example #20
0
 public function actionEditPrem()
 {
     if ($this->_isPost()) {
         $roleValue = strtolower($_POST['role_value']);
         $selectIds = $_POST['Id'];
         if (!$selectIds) {
             $selectIds = array();
         }
         $dataList = $this->_modelAct->findAll();
         foreach ($dataList as &$value) {
             if ($value['allow'] == RBAC_EVERYONE) {
                 continue;
             }
             //如果是所有用户将跳过不执行
             if (empty($value['allow'])) {
                 $roles = array();
             } else {
                 $roles = explode(',', $value['allow']);
                 //获取当前模板的所有角色
             }
             $key = array_search($value['Id'], $selectIds);
             //搜索用户是否选中此模块
             if ($key === false) {
                 //如果没有找到,就表示用户让角色对此模块没有权限,将更新此模块删除allow字段里这个角色
                 $rolesKey = array_search($roleValue, $roles);
                 if ($rolesKey !== false) {
                     unset($roles[$rolesKey]);
                 }
                 //如果有这个角色,将删除这个角色
                 $roles = implode(',', $roles);
                 $updateArr = array('allow' => $roles);
             } else {
                 //否则将加上这个角色,并且更新allow字段
                 $rolesKey = array_search($roleValue, $roles);
                 if ($rolesKey !== false) {
                     continue;
                 }
                 //如果找到此值,就说明此模块已经有这个角色,不用做操作.
                 array_push($roles, $roleValue);
                 $roles = implode(',', $roles);
                 $updateArr = array('allow' => $roles);
             }
             $this->_modelAct->update($updateArr, "Id={$value['Id']}");
         }
         $rbac = $this->_getGlobalData('Util_Rbac', 'object');
         $rbac->createAct();
         $this->_utilMsg->showMsg('更新成功', 1);
     } else {
         #------获得菜单项一维数组------#
         $this->_modelMenu = $this->_getGlobalData('Model_Menu', 'object');
         $menuList = $this->_modelMenu->findAll();
         $menuArr = array();
         foreach ($menuList as $value) {
             $menuArr[$value['value']] = $value['name'];
         }
         #------获得菜单项一维数组------#
         $roleValue = strtolower($_GET['role_value']);
         $dataList = $this->_modelAct->findAll();
         $controlList = array();
         $actionList = array();
         $selectedList = array();
         foreach ($dataList as &$value) {
             $value['value'] = "{$menuArr[$value['value']]}.{$value['value']}";
             $roles = explode(',', $value['allow']);
             if (in_array($roleValue, $roles) || $value['allow'] == RBAC_EVERYONE) {
                 array_push($selectedList, $value['Id']);
             }
             if ($value['parent_id'] == 0) {
                 array_push($controlList, $value);
             } else {
                 array_push($actionList, $value);
             }
         }
         $controlList = $this->_modelAct->getTtwoArrConvertOneArr($controlList, 'Id', 'value');
         $checkBox = '';
         foreach ($controlList as $key => $value) {
             $checkBox .= '<tr><td align="left">';
             $checked = in_array($key, $selectedList) ? 'checked="checked"' : '';
             $checkBox .= "<input type='checkbox' value={$key} name='Id[]' {$checked} /><b>{$value}</b><hr />";
             foreach ($actionList as $childValue) {
                 if ($childValue['parent_id'] == $key) {
                     $checked = in_array($childValue['Id'], $selectedList) ? 'checked="checked"' : '';
                     $checkBox .= "&nbsp;&nbsp;&nbsp;→<input type='checkbox' value={$childValue['Id']} name='Id[]' {$checked} />{$childValue['value']}<br/>";
                 }
             }
             $checkBox .= '</td></tr>';
         }
         $this->_view->assign('checkBox', $checkBox);
         $this->_view->assign('roleValue', $roleValue);
         $this->_view->assign('css', $this->_view->get_curCss());
         $this->_utilMsg->createNavBar();
         $this->_view->display();
     }
 }
Example #21
0
 /**
  * 请求数据检测
  * 
  * @return mixed
  */
 public function _checkData($sType = 'add')
 {
     $sPermissionName = $this->getParam('sPermissionName');
     $sPath = $this->getParam('sPath');
     $iMenuID = $this->getParam('iMenuID');
     if (!Util_Validate::isLength($sPermissionName, 2, 30)) {
         return $this->showMsg('权限名长度范围为2到30个字!', false);
     }
     if (!Util_Validate::isLength($sPath, 2, 50)) {
         return $this->showMsg('权限点长度范围为2到30个字符!', false);
     }
     if (empty($iMenuID)) {
         return $this->showMsg('请选择权限点的归属模块!', false);
     }
     $iCnt = Model_Menu::getCnt(array('where' => array('iParentID' => $iMenuID)));
     if ($iCnt > 0) {
         return $this->showMsg('归属模块只能选择最底层的模块!', false);
     }
     $aRow = array('sPermissionName' => $sPermissionName, 'sPath' => $sPath, 'iMenuID' => $iMenuID);
     return $aRow;
 }
Example #22
0
 public function blogAction()
 {
     $ispost = $this->_getParam('idpost', false);
     $this->view->pageTitle = $this->view->tr(NULL, $this->view->lang, 'Наш Блог');
     if ($ispost) {
         $this->view->token = new Zend_Service_ReCaptcha($this->config->capcha->pub, $this->config->capcha->priv);
         if ($this->_request->isPost()) {
             $filter = new Zend_Filter();
             $filter = $filter->addFilter(new Zend_Filter_StripTags())->addFilter(new Zend_Filter_HtmlEntities());
             $name = $filter->filter($this->_getParam('name', ''));
             $email = $filter->filter($this->_getParam('email', ''));
             $message = $filter->filter($this->_getParam('message', ''));
             $token = $this->_getParam('token', '');
             $data = array('name' => $name, 'email' => $email, 'message' => $message, 'idpage' => $ispost);
             $recaptcha_challenge_field = $this->_getParam('recaptcha_challenge_field', 'default');
             $recaptcha_response_field = $this->_getParam('recaptcha_response_field', 'default');
             $result = $this->view->token->verify($recaptcha_challenge_field, $recaptcha_response_field);
             //var_dump($recaptcha_challenge_field, $recaptcha_response_field);
             if ($result->isValid()) {
                 Model_Comment::updatepage($data);
                 // send mail
                 try {
                     $mail = new Zend_Mail($charset = 'utf-8');
                     $mail->addTo($this->view->config->resources->mail->admin);
                     $mail->setFrom($this->view->config->resources->mail->sender);
                     $text = $this->view->config->resources->mail->template;
                     $text = "Був доданий коментар до сторінки " . $this->view->config->baseurl . $this->getRequest()->getRequestUri() . "\n";
                     $text .= "Дата: " . $this->view->localDate(time(), $this->view->lang) . "\n";
                     $text .= "Имя: {$name} \n";
                     $text .= "Email: {$email} \n";
                     $text .= "Текст: {$message} \n";
                     $mail->setSubject('Коментар на сайті Party Zone');
                     $mail->setBodyText($text);
                     $t = $mail->send();
                 } catch (Zend_Mail_Exception $e) {
                     echo json_encode(array('status' => 'error', 'msg' => $e->getMessages()));
                     // exit;
                 }
                 $this->_redirect($this->getRequest()->getRequestUri());
             }
         }
         $this->view->comments = Model_Comment::getAll($ispost, 'asc');
         $this->view->post = Model_Blogentry::getById($ispost, $this->view->lang);
         if (is_object($this->view->post)) {
             $this->view->pageTitle = $this->view->post->title;
             $this->view->headMeta()->appendName('keywords', $this->view->post->keyword);
             $this->view->headMeta()->appendName('description', $this->view->post->description);
         }
         return $this->renderScript('/index/blogentry.phtml');
     }
     $this->view->blogs = $this->setPaginator(Model_Blogentry::getBlogs($this->view->lang));
     $this->view->blogmenu = Model_Menu::getById(16, $this->view->lang);
 }
Example #23
0
 * This file was automatically generated By Code Smith 
 * Modifications will be overwritten when code smith is run
 *
 * PLEASE DO NOT MAKE MODIFICATIONS TO THIS FILE
 * Date Created 5/6/2012
 *
 */
/// <summary>
/// Implementations of slmenus represent a Menu
///
/// </summary>
chdir("..");
/* TODO: Add code here */
require 'config/globalconfig.php';
include_once 'class/model_menu.php';
$objMenu = new Model_Menu($objConnection);
if ($_pgR["act"] == model_Menu::ACT_ADD) {
    if (global_common::isCLogin()) {
        //get user info
        //$c_userInfo = $_SESSION[consts::SES_C_USERINFO];
        //if ($objMenu->getMenuByName($_pgR['name'])) {
        //	echo global_common::convertToXML($arrHeader, array("rs",'info'), array(0,global_common::STRING_NAME_EXIST), array(0,1));
        //	return;
        //}
        $menuID = $_pgR['MenuID'];
        $menuID = global_editor::rteSafe(html_entity_decode($menuID, ENT_COMPAT, 'UTF-8'));
        $menuName = $_pgR['MenuName'];
        $menuName = global_editor::rteSafe(html_entity_decode($menuName, ENT_COMPAT, 'UTF-8'));
        $link = $_pgR['Link'];
        $link = global_editor::rteSafe(html_entity_decode($link, ENT_COMPAT, 'UTF-8'));
        $numOrder = $_pgR['NumOrder'];
Example #24
0
 /**
  * 用户权限分配 
  */
 private function _userAct()
 {
     if ($this->_isPost()) {
         $userId = $_POST['user_id'];
         $idArr = $_POST['Id'];
         if ($idArr) {
             $idArr = implode(',', $idArr);
         } else {
             $idArr = null;
         }
         $this->_modelUser->update(array('act' => $idArr), "Id={$userId}");
         $this->_utilMsg->showMsg('增加权限成功', 1, Tools::url(CONTROL, ACTION));
     } else {
         $moudlesUrl = $this->_getMoudlesUrl();
         $this->_view->assign('moudlesUrl', $moudlesUrl);
         #------获得菜单项一维数组------#
         $this->_modelMenu = $this->_getGlobalData('Model_Menu', 'object');
         $menuList = $this->_modelMenu->findAll();
         $menuArr = array();
         foreach ($menuList as $value) {
             $menuArr[$value['value']] = $value['name'];
         }
         #------获得菜单项一维数组------#
         $userId = Tools::coerceInt($_GET['user_id']);
         $this->_modelAct = $this->_getGlobalData('Model_Act', 'object');
         $dataList = $this->_modelAct->getUseRoleAct($userId);
         $controlList = array();
         $actionList = array();
         $selectedList = array();
         foreach ($dataList as &$value) {
             if ($value['selected']) {
                 $selectedList[$value['Id']] = $value['selected'];
             }
             if ($value['parent_id'] == 0) {
                 array_push($controlList, $value);
             } else {
                 array_push($actionList, $value);
             }
         }
         $checkBox = '';
         foreach ($controlList as $key => $value) {
             $checkBox .= '<tr><td align="left">';
             $checked = array_key_exists($value['Id'], $selectedList) ? 'checked="checked"' : '';
             if ($checked != '') {
                 if ($selectedList[$value['Id']] == 1) {
                     $checked .= " disabled='disabled'' ";
                 }
                 //如果等于1就表示这个选中的按钮是通过角色选中的
             }
             $checkBox .= "<input type='checkbox' value='{$value['value']}' name='Id[]' {$checked} /><b>{$menuArr[$value['value']]}.{$value['value']}</b><hr />";
             foreach ($actionList as $childValue) {
                 if ($childValue['parent_id'] == $value['Id']) {
                     $checked = array_key_exists($childValue['Id'], $selectedList) ? 'checked="checked"' : '';
                     if ($checked != '') {
                         if ($selectedList[$childValue['Id']] == 1) {
                             $checked .= " disabled='disabled'' ";
                         }
                         //如果等于1就表示这个选中的按钮是通过角色选中的
                     }
                     $checkBox .= "&nbsp;&nbsp;&nbsp;→<input type='checkbox' value='{$childValue['value']}' name='Id[]' {$checked} />{$menuArr[$childValue['value']]}.<a href='javascript:;' val_data='{$childValue['value']}' name='user_act'>{$childValue['value']}</a><br/>";
                 }
             }
             $checkBox .= '</td></tr>';
         }
         $this->_view->assign('checkBox', $checkBox);
         $this->_utilMsg->createNavBar();
         $this->_view->set_tpl(array('body' => 'User/UserAct.html'));
         $this->_view->display();
     }
 }
Example #25
0
 /**
  *
  * @return Zend_Navigation
  */
 public function pages($pPanel = 'main')
 {
     return Model_Menu::getInstance()->pages($pPanel);
 }
Example #26
0
 private function _delMain()
 {
     $this->_modelMenu->execute("delete from {$this->_modelMenu->tName()} where Id={$_GET['Id']}");
     $this->_modelMenu->execute("delete from {$this->_modelMenu->tName()} where parent_id={$_GET['Id']}");
     $this->_utilMsg->showMsg(Tools::getLang('DEL_SUCESS', 'Common'), 1);
 }
Example #27
0
 private function _delMain()
 {
     $this->_modelMenu->execute("delete from {$this->_modelMenu->tName()} where Id={$_GET['Id']}");
     $this->_modelMenu->execute("delete from {$this->_modelMenu->tName()} where parent_id={$_GET['Id']}");
     $this->_utilMsg->showMsg('删除成功', 1);
 }
Example #28
0
 protected function prep_props(array $props)
 {
     // Skip tree fields and primary keys
     $skip_fields = \Arr::merge(Model_Menu::primary_key(), Model_Menu::tree_config(), array('children'));
     \Arr::delete($skip_fields, array('read-only', 'title_field'));
     // Model properties
     $properties = \Arr::filter_keys($props, array_keys(Model_Menu::properties()));
     $properties = \Arr::filter_keys($properties, $skip_fields, true);
     //Model 'fields' property fields
     $fields = \Arr::filter_keys($props, array_keys($properties), true);
     $fields = \Arr::filter_keys($fields, $skip_fields, true);
     is_array($properties['fields']) or $properties['fields'] = array();
     $properties['fields'] = \Arr::merge($properties['fields'], $fields);
     return $properties;
 }
Example #29
0
 public function savemenuAction()
 {
     if ($this->_request->isPost()) {
         $t = Model_Menu::getById($this->_getParam('idmenu'));
         if ($t->blockedit == $this->_getParam('blockedit') && $t->blockedit == 'block') {
             $this->_redirect('/admin/menu/item/' . $this->_getParam('idmenu'));
         }
         //var_dump($_POST);exit;
         $input = $this->menuvalid($_POST);
         if ($input->isValid()) {
             $res = Model_Menu::updatemenu($input);
             if ($res[0] > 0) {
                 // Якщо це створення нового обєкта та збережено з мовою по запиту,
                 // зберігаємо варіант для інших мов
                 //if ($_POST['idmenu'] == 'new') {
                 $ll = $input->lang;
                 foreach ($this->view->langs as $key) {
                     $t = Model_Menu::getById($this->_getParam('idmenu'), $key);
                     if (!is_null($t->idmenu)) {
                         continue;
                     }
                     if ($key !== $ll) {
                         $data = $_POST;
                         $data['idmenu'] = $res[1];
                         $data['lang'] = $key;
                         $input = $this->menuvalid($data);
                         Model_Menu::updatemenu($input);
                     }
                 }
                 //}
                 // Якщо ні просто переходимо до редактування обєкту
                 $this->_redirect('/admin/menu/item/' . $res[1] . '/lang/' . $_POST['lang']);
             } else {
                 if (count($res[1]) > 1) {
                     echo "Ошибка! " . $res[1];
                     exit;
                 } else {
                     echo "Редагування цього запису заблоковано.";
                     exit;
                 }
             }
         }
         $t = $input->getMessages();
         if (count($t) > 0) {
             echo "Ошибка! " . var_dump($t);
             exit;
         } else {
             echo "Редагування цього запису заблоковано2.";
             exit;
         }
     }
 }
Example #30
0
 /**
  *
  * @return void
  */
 public function load_menus($pReload = FALSE)
 {
     if ($pReload || !$this->menu_loaded) {
         if ($config = $this->menu_data()) {
             $mm = Model_Menu::getInstance();
             $crit = $mm->table()->getAdapter()->quoteInto('created_by_module = ?', $this->folder);
             $mm->table()->delete($crit);
             $data = $config->toArray();
             $mm->add_menus($data, $this->folder);
         }
         $this->menu_loaded = TRUE;
         $this->save();
     }
 }