コード例 #1
0
 function getOptions($id = null)
 {
     if (!$this->model) {
         $this->model = new waContactCategoryModel();
     }
     if (!$this->categories) {
         $this->categories = $this->model->getALl('id');
     }
     // Checklist options, category_id => name
     $options = array();
     foreach ($this->categories as $id => $row) {
         $options[$id] = $row['name'];
     }
     // Admins are allowed to see everything, and person outside of contacts app can see a list of categories too
     if (wa()->getApp() != 'contacts' || wa()->getUser()->getRights('contacts', 'category.all')) {
         return $options;
     }
     // Only load categories available for current user
     $crm = new contactsRightsModel();
     $allowed = $crm->getAllowedCategories();
     foreach ($options as $id => $row) {
         if (!isset($allowed[$id])) {
             unset($options[$id]);
         }
     }
     return $options;
 }
コード例 #2
0
 public function getInfo()
 {
     $info = parent::getInfo();
     if (!$this->model) {
         $this->model = new waContactCategoryModel();
     }
     if (!$this->categories) {
         $this->categories = $this->model->getALl('id');
     }
     // System categories are disabled
     $info['disabled'] = array();
     foreach ($this->categories as $id => $row) {
         if ($row['system_id']) {
             $info['disabled'][$id] = true;
         }
     }
     return $info;
 }