コード例 #1
0
ファイル: restapi_misc.php プロジェクト: IASA-GR/appdb-core
 /**
  * @overrides get() from RestResource
  */
 public function get()
 {
     if (parent::get() !== false) {
         $res = new Default_Model_Categories();
         if (is_numeric($this->getParam("id"))) {
             $res->filter->id->numequals($this->getParam("id"));
         } elseif (substr($this->getParam("id"), 0, 2) === "s:") {
             $res->filter->name->ilike(substr($this->getParam("id"), 2));
         } else {
             return false;
         }
         $res->refresh("xml", true);
         return new XMLFragmentRestResponse($res->items, $this);
     } else {
         return false;
     }
 }
コード例 #2
0
 public function getCategory()
 {
     if ($this->_category === null) {
         $Categories = new Default_Model_Categories();
         $Categories->filter->id->equals($this->getCategoryID());
         if ($Categories->count() > 0) {
             $this->_category = $Categories->items[0];
         }
     }
     return $this->_category;
 }
コード例 #3
0
ファイル: Helper.php プロジェクト: rajbrt/sentrifugo
 /**
  ** Function to display Policy documents categories
  ** Based on privileges for View/Manage Policy documents, categories are listed as menu items
  ** 1. get categories created for policy documents
  ** 2. build menu with respective urls
  **/
 public static function viewPolicyDocuments($call)
 {
     /**
      * Instantiate categories model
      * to get categories and documents count for each category
      **/
     $categoriesModel = new Default_Model_Categories();
     $dataObj = $categoriesModel->getCategories('menu');
     $categoriesObj = $documentsObj = '';
     $documentsCntArr = array();
     if (!empty($dataObj)) {
         $categoriesObj = $dataObj['res'];
         $documentsObj = $dataObj['docs'];
         /** 
          ** looping through documents object
          ** to build an array with category_id as index and documents count as value
          **/
         if (!empty($documentsObj)) {
             for ($i = 0; $i < sizeof($documentsObj); $i++) {
                 $documentsCntArr[$documentsObj[$i]['category_id']] = $documentsObj[$i]['doccnt'];
             }
         }
     }
     $html = '';
     /**
      ** looping through categories object
      ** to build menu items under Organization > Policy documents
      ** with documents count for each category/menu item
      **/
     if (!empty($categoriesObj)) {
         $html .= '    <ul>';
         for ($c = 0; $c < sizeof($categoriesObj); $c++) {
             $catId = $categoriesObj[$c]['id'];
             $url = BASE_URL . 'policydocuments/id/' . $catId;
             $html .= '<li menu-url="' . $url . '" parent-div="div_mchilds_' . ORGANIZATION . '" super-parent="main_parent_' . ORGANIZATION . '" class="clickable_menu set_over_text" primary_parent="' . POLICY_DOCUMENTS . '"><a href="' . ($call == 'menusettings' ? "javascript:void(0);" : $url) . '"><i class="span_sermenu">' . $categoriesObj[$c]['category'] . '</i> ';
             if (isset($documentsCntArr[$catId]) && !empty($documentsCntArr[$catId])) {
                 $html .= '<b class="super_cnt">' . $documentsCntArr[$catId] . '</b></a></li>';
             } else {
                 $html .= '<b class="super_cnt">0</b></a></li>';
             }
         }
         $html .= '    </ul>';
     }
     return $html;
 }
コード例 #4
0
 /**
  ** Function used to allow adding of multiple policy documents at a time
  **/
 public function addmultipleAction()
 {
     try {
         /**
          ** to display "Add Multiple Documents" link, check add privileges for the logged in user 
          **/
         $popConfigPermission = array();
         if (sapp_Global::_checkprivileges(MANAGE_POLICY_DOCS, $this->loggedInUserGroup, $this->loggedInUserRole, 'add') == 'Yes') {
             /**
              ** capturing referral URL, to redirect after adding policy document
              **/
             $redirectUrl = '';
             if (isset($_SERVER['HTTP_REFERER'])) {
                 $httpReferrer = $_SERVER['HTTP_REFERER'];
                 $redirectUrl = str_replace(BASE_URL, '', $httpReferrer);
                 if (strpos($redirectUrl, 'addmultiple') === false) {
                     $this->view->redirectUrl = $redirectUrl;
                 }
             }
             /** capture category id **/
             $category_id = $this->getRequest()->getParam('id');
             $category_id = (int) $category_id;
             /**
              ** if category id is available
              ** load the form
              ** else redirect to invalid url page
              **/
             if ($category_id) {
                 /**
                  ** Initiating category form
                  ** and assigning action
                  **/
                 $multipleDocsForm = new Default_Form_Policydocuments();
                 $this->view->form = $multipleDocsForm;
                 $multipleDocsForm->setAttrib('action', BASE_URL . 'policydocuments/addmultiple/' . $category_id);
                 /**
                  ** Get category by id
                  ** populate category in select control
                  **/
                 $categoriesModel = new Default_Model_Categories();
                 $categoriesObj = $categoriesModel->getCategoryById($category_id);
                 if (!empty($categoriesObj)) {
                     $multipleDocsForm->category_id->addMultiOption($categoriesObj['id'], utf8_encode($categoriesObj['category']));
                 }
                 $multipleDocsForm->setDefault('category_id', $category_id);
                 $this->view->category_id = $category_id;
                 if ($this->getRequest()->getPost()) {
                     $this->saveMultipleDoc($multipleDocsForm, $category_id, $redirectUrl);
                 }
             } else {
                 $this->view->ermsg = 'invalidUrl';
                 return;
             }
         } else {
             $this->view->ermsg = 'noprivilege';
         }
     } catch (Exceptin $e) {
         //print_r($e);
     }
 }