コード例 #1
0
ファイル: UsersController.php プロジェクト: valizr/MMA
 public function editAction()
 {
     require_once APPLICATION_PUBLIC_PATH . '/library/tsThumb/ThumbLib.inc.php';
     Needs_Roles::hasAccess('editare_utilizator', true);
     $page = $this->getRequest()->getParam('page') ? (int) $this->getRequest()->getParam('page') : 1;
     $this->view->page = $page;
     $id = $this->getRequest()->getParam('id');
     $model = new Default_Model_Users();
     if ($model->find($id)) {
         $form = new Default_Form_Users();
         $form->edit($model);
         $form->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/users/edit-user.phtml'))));
         $this->view->form = $form;
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->getRequest()->getPost())) {
                 $model->setOptions($form->getValues());
                 if ($model->save()) {
                     //Needs_Tools::DeleteLegaturiDistrictManager( $model->getId() );
                     //						if($form->getValue('idRole') == 14){
                     //							foreach ($form->getValue('idShopMulti') as $idShop) {
                     //								$modelDistrictManager = new Default_Model_DistrictManagerShops();
                     //								$modelDistrictManager->setIdShop($idShop);
                     //								$modelDistrictManager->setIdUser($model->getId());
                     //								$modelDistrictManager->save();
                     //							}
                     //						}
                     $this->_flashMessenger->addMessage("<div class='success  canhide'><p>User was edited successfully!<a href='javascript:;'>Close</a></p></div>");
                 } else {
                     $this->_flashMessenger->addMessage("<div class='failure  canhide'><p>User was not edited!<a href='javascript:;'>Close</a></p></div>");
                 }
                 $this->_redirect('/users/index/page/' . $page);
             }
         }
     }
 }
コード例 #2
0
ファイル: AjaxController.php プロジェクト: valizr/MMA
 public function showChildsAction()
 {
     $optionArray = array();
     $webRoot = $this->view->baseUrl();
     if (Needs_Roles::hasAccess(Zend_Registry::get('user')->getIdRole(), 'adaugare_rol')) {
         $optionArray['addSubLink'] = $webRoot . '/role/add/id/';
         $optionArray['subName'] = 'subrol';
     }
     if (Needs_Roles::hasAccess(Zend_Registry::get('user')->getIdRole(), 'editare_rol')) {
         $optionArray['editLink'] = $webRoot . '/role/edit/id/';
     }
     if (Needs_Roles::hasAccess(Zend_Registry::get('user')->getIdRole(), 'stergere_rol')) {
         $optionArray['deleteLink'] = $webRoot . '/role/delete/id/';
     }
     $response = '';
     $id = $this->getRequest()->getParam('id');
     $parent = $this->getRequest()->getParam('parent');
     $role = new Default_Model_Role();
     $role->find($id);
     //if first, show parent node
     $showParent = $parent == 'true' ? true : false;
     $graph = new Needs_Graph($role, $showParent, array('idParent', 'id', 'name'), 'object', true);
     $childRoles = $graph->getTree();
     if ($childRoles) {
         $last = count($childRoles) - 1;
         $response .= "<div class='show-users'>";
         foreach ($childRoles as $key => $value) {
             $first = $value->getId() == Zend_Registry::get('user')->getIdRole() ? true : false;
             $paddingFirst = !$first ? '20px' : '0';
             $isFirst = $key == 0 ? 'first' : '';
             $isLast = $last == $key ? 'last' : '';
             $hasChild = Needs_Graph::hasChild($value) && !$first ? true : false;
             $afterLinks = '';
             if ($hasChild) {
                 $afterLinks .= "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<a id='jsColapse-{$value->getId()}' class='jsColapse' rel='{$value->getId()}' href='javascript:;' title='Colapse'></a>\t\t\t\t\t\t\t\n\t\t\t\t\t";
             }
             $afterLinks .= "<a class='user-info listingItem roleListing' href='javascript:;' rel='{$value->getId()}' title='Informatii'></a>";
             if (!empty($optionArray['addSubLink'])) {
                 $afterLinks .= '<a class="user-add-child" href="' . $optionArray['addSubLink'] . $value->getId() . '" title="Adauga ' . $optionArray['subName'] . '"></a>';
             }
             if (!empty($optionArray['editLink']) && Zend_Registry::get('user')->getIdRole() != $value->getId()) {
                 $afterLinks .= ' <a class="user-edit" href="' . $optionArray['editLink'] . $value->getId() . '" title = "Editare"></a>';
             }
             if (!empty($optionArray['deleteLink']) && Zend_Registry::get('user')->getIdRole() != $value->getId()) {
                 $afterLinks .= ' <a class="user-delete confirmDelete" href="' . $optionArray['deleteLink'] . $value->getId() . '" title="Stergere"></a>';
             }
             $response .= "<div id='user-{$value->getId()}' class='user {$isFirst} {$isLast} listingDiv' style='margin-left: {$paddingFirst}'>\n\t\t\t\t\t\t\t<a class='listingItem roleListing fl' href='javascript:;' rel='{$value->getId()}'>{$value->getName()}</a>\t\n\t\t\t\t\t\t\t<div class='fr'>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t<div class='user-actions'>\n\t\t\t\t\t\t\t\t\t{$afterLinks}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t ";
             $response .= "\n\t\t\t\t\t\t<div class='clear'></div>\n\t\t\t\t\t";
             $response .= "\n\t\t\t\t\t</div>\n\t\t\t\t\t";
             if ($hasChild) {
                 $response .= "<div class='child-element' id='load-child-{$value->getId()}'></div>";
             }
         }
         $response .= '</div>';
     }
     echo Zend_Json_Encoder::encode($response);
 }