public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->field_id && canEdit('system')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->field_id && canEdit('system')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     return $stored;
 }
Пример #2
0
 public function __construct($key = null, $title = null, $value = null)
 {
     parent::__construct('sysvals', 'sysval_id');
     $this->sysval_key_id = $key;
     $this->sysval_title = $title;
     $this->sysval_value = $value;
 }
Пример #3
0
 public function __construct($name = null, $label = null, $type = '0', $sep1 = "\n", $sep2 = '|')
 {
     parent::__construct('syskeys', 'syskey_id');
     $this->syskey_name = $name;
     $this->syskey_label = $label;
     $this->syskey_type = $type;
     $this->syskey_sep1 = $sep1;
     $this->syskey_sep2 = $sep2;
 }
Пример #4
0
 public function store($unused = null)
 {
     $stored = false;
     //TODO: Why isn't there a canCreate branch here?
     if ($this->canEdit()) {
         $stored = parent::store();
     }
     return $stored;
 }
 protected function hook_preStore()
 {
     $this->pd_option_user = $this->_AppUI->user_id;
     $pd_options = $this->loadAll(null, 'pd_option_user = '******'pd_option_id'];
         }
     }
     $this->pd_option_id = $pd_options_id;
     parent::hook_preStore();
 }
Пример #6
0
 protected function hook_preStore()
 {
     if ($this->budget_start_date) {
         $date = new w2p_Utilities_Date($this->budget_start_date);
         $this->budget_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->budget_end_date) {
         $date = new w2p_Utilities_Date($this->budget_end_date);
         $this->budget_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     parent::hook_preStore();
 }
Пример #7
0
 public function delete(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $this->_error = array();
     if ($perms->checkModuleItem('resources', 'delete', $this->resource_id)) {
         if ($msg = parent::delete()) {
             return $msg;
         }
         return true;
     }
     return false;
 }
Пример #8
0
 public function store()
 {
     $stored = false;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $q = $this->_getQuery();
     //TODO: this is an oddball permissions object where the module doesn't determine the access..
     if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem('forums', 'edit', $this->{$this->_tbl_module})) {
         $q->setDelete('forum_visits');
         $q->addWhere('visit_message = ' . (int) $this->message_id);
         $q->exec();
         if ($msg = parent::store()) {
             $this->_error['store'] = $msg;
         } else {
             $stored = true;
         }
     }
     if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem('forums', 'add')) {
         $this->message_date = $q->dbfnNowWithTZ();
         if ($msg = parent::store()) {
             $this->_error['store'] = $msg;
         } else {
             $q->addTable('forum_messages');
             $q->addQuery('count(message_id), MAX(message_date)');
             $q->addWhere('message_forum = ' . (int) $this->message_forum);
             $reply = $q->fetchRow();
             //update forum descriptor
             $forum = new CForum();
             $forum->overrideDatabase($this->_query);
             $forum->load(null, $this->message_forum);
             $forum->forum_message_count = $reply[0];
             /*
              * Note: the message_date here has already been adjusted for the
              *    timezone above, so don't do it again!
              */
             $forum->forum_last_date = $this->message_date;
             $forum->forum_last_id = $this->message_id;
             $forum->store();
             $this->sendWatchMail(false);
             $stored = true;
         }
     }
     return $stored;
 }
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $stored = false;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $q = new w2p_Database_Query();
     if ($this->message_id && $perms->checkModuleItem('forums', 'edit', $this->forum_id)) {
         $q->setDelete('forum_visits');
         $q->addWhere('visit_message = ' . (int) $this->message_id);
         $q->exec();
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->message_id && $perms->checkModuleItem('forums', 'add')) {
         $this->message_date = $q->dbfnNowWithTZ();
         if ($msg = parent::store()) {
             return $msg;
         }
         $q->addTable('forum_messages');
         $q->addQuery('count(message_id), MAX(message_date)');
         $q->addWhere('message_forum = ' . (int) $this->message_forum);
         $reply = $q->fetchRow();
         //update forum descriptor
         $forum = new CForum();
         $forum->load($AppUI, $this->message_forum);
         $forum->forum_message_count = $reply[0];
         /*
          * Note: the message_date here has already been adjusted for the
          *    timezone above, so don't do it again!
          */
         $forum->forum_last_date = $this->message_date;
         $forum->forum_last_id = $this->message_id;
         $forum->store($AppUI);
         $this->sendWatchMail(false);
         $stored = true;
     }
     return $stored;
 }
Пример #10
0
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *     don't have a good idea on how to fix it at the moment...
      */
     if ($this->holiday_id && $perms->checkModuleItem('holiday', 'edit', $this->holiday_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->holiday_id && $perms->checkModuleItem('holiday', 'add')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     return $stored;
 }
Пример #11
0
 public function delete($unused = null)
 {
     $result = false;
     if ($this->canDelete()) {
         $q = $this->_getQuery();
         $q->addTable('forum_messages');
         $q->addQuery('message_forum');
         $q->addWhere('message_id = ' . (int) $this->message_id);
         $forumId = $q->loadResult();
         $q->clear();
         $q->setDelete('forum_messages');
         $q->addWhere('message_id = ' . (int) $this->message_id);
         $result = parent::delete();
         $q->addTable('forum_messages');
         $q->addQuery('COUNT(message_id)');
         $q->addWhere('message_forum = ' . (int) $forumId);
         $messageCount = $q->loadResult();
         $q->clear();
         $q->addTable('forums');
         $q->addUpdate('forum_message_count', $messageCount);
         $q->addWhere('forum_id = ' . (int) $forumId);
         $q->exec();
     }
     return $result;
 }
Пример #12
0
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $stored = false;
     $this->w2PTrimAll();
     // ensure changes of state in checkboxes is captured
     $this->project_active = (int) $this->project_active;
     $this->project_private = (int) $this->project_private;
     $this->project_target_budget = filterCurrency($this->project_target_budget);
     $this->project_actual_budget = filterCurrency($this->project_actual_budget);
     // Make sure project_short_name is the right size (issue for languages with encoded characters)
     $this->project_short_name = mb_substr($this->project_short_name, 0, 10);
     if (empty($this->project_end_date)) {
         $this->project_end_date = null;
     }
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $this->project_id = (int) $this->project_id;
     // convert dates to SQL format first
     if ($this->project_start_date) {
         $date = new w2p_Utilities_Date($this->project_start_date);
         $this->project_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_end_date) {
         $date = new w2p_Utilities_Date($this->project_end_date);
         $date->setTime(23, 59, 59);
         $this->project_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_actual_end_date) {
         $date = new w2p_Utilities_Date($this->project_actual_end_date);
         $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     // check project parents and reset them to self if they do not exist
     if (!$this->project_parent) {
         $this->project_parent = $this->project_id;
         $this->project_original_parent = $this->project_id;
     } else {
         $parent_project = new CProject();
         $parent_project->load($this->project_parent);
         $this->project_original_parent = $parent_project->project_original_parent;
     }
     if (!$this->project_original_parent) {
         $this->project_original_parent = $this->project_id;
     }
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     $q = $this->_query;
     $this->project_updated = $q->dbfnNowWithTZ();
     if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->project_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) {
         $this->project_created = $q->dbfnNowWithTZ();
         if ($msg = parent::store()) {
             return $msg;
         }
         if (0 == $this->project_parent || 0 == $this->project_original_parent) {
             $this->project_parent = $this->project_id;
             $this->project_original_parent = $this->project_id;
             if ($msg = parent::store()) {
                 return $msg;
             }
         }
         $stored = true;
     }
     //split out related departments and store them seperatly.
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_departments) {
         foreach ($this->project_departments as $department) {
             if ($department) {
                 $q->addTable('project_departments');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('department_id', $department);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('project_contacts');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_contacts) {
         foreach ($this->project_contacts as $contact) {
             if ($contact) {
                 $q->addTable('project_contacts');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('contact_id', $contact);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     if ($stored) {
         $custom_fields = new w2p_Core_CustomFields('projects', 'addedit', $this->project_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->project_id);
         // Store Custom Fields
         CTask::storeTokenTask($AppUI, $this->project_id);
     }
     return $stored;
 }
Пример #13
0
 protected function hook_preStore()
 {
     $this->file_folder_id = (int) $this->file_folder_id;
     $this->file_folder_parent = (int) $this->file_folder_parent;
     parent::hook_preStore();
 }
Пример #14
0
 public function __construct()
 {
     parent::__construct('config', 'config_id');
 }
Пример #15
0
 /**
  * Get a list of task logs the current user is allowed to access
  *
  * @global AppUI $AppUI global user permissions
  * @param int $uid user id to test
  * @param string $fields optional fields to be returned by the query, default is all
  * @param string $orderby optional sort order for the query
  * @param int $index optional name of field to index the returned array
  * @param array $extra optional array of additional sql parameters (from and where supported)
  *
  * @return array
  */
 public function getAllowedRecords($uid, $fields = '*', $orderby = '', $index = null, $extra = null)
 {
     $oTsk = new CTask();
     $oTsk->overrideDatabase($this->_query);
     $aTasks = $oTsk->getAllowedRecords($uid, 'task_id, task_name');
     if (count($aTasks)) {
         $buffer = '(task_log_task IN (' . implode(',', array_keys($aTasks)) . ') OR task_log_task IS NULL OR task_log_task = \'\' OR task_log_task = 0)';
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND ' . $buffer;
         } else {
             $extra['where'] = $buffer;
         }
     } else {
         // There are no allowed tasks, so don't allow task_logs.
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND 1 = 0 ';
         } else {
             $extra['where'] = '1 = 0';
         }
     }
     return parent::getAllowedRecords($uid, $fields, $orderby, $index, $extra);
 }
Пример #16
0
 public function __construct()
 {
     parent::__construct('departments', 'dept_id');
 }
Пример #17
0
 public function __construct($table, $key, $module = '')
 {
     parent::__construct($table, $key, $module);
     trigger_error("CW2pObject has been deprecated in v2.0 and will be removed by v4.0. Please use w2p_Core_BaseObject instead.", E_USER_NOTICE);
 }
Пример #18
0
 /**
  **	Overload of the w2PObject::getAllowedRecords
  **	to ensure that the allowed projects are owned by allowed companies.
  **
  **	@author	handco <*****@*****.**>
  **	@see	w2PObject::getAllowedRecords
  **/
 public function getAllowedRecords($uid, $fields = '*', $orderby = '', $index = null, $extra = null)
 {
     global $AppUI;
     $oCpy = new CCompany();
     $aCpies = $oCpy->getAllowedRecords($uid, 'company_id, company_name');
     if (count($aCpies)) {
         $buffer = '(contact_company IN (' . implode(',', array_keys($aCpies)) . ') OR contact_company IS NULL OR contact_company = \'\' OR contact_company = 0)';
         //Department permissions
         $oDpt = new CDepartment();
         $aDpts = $oDpt->getAllowedRecords($uid, 'dept_id, dept_name');
         if (count($aDpts)) {
             $dpt_buffer = '(contact_department IN (' . implode(',', array_keys($aDpts)) . ') OR contact_department = 0)';
         } else {
             // There are no allowed departments, so allow projects with no department.
             $dpt_buffer = '(contact_department = 0)';
         }
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND ' . $buffer . ' AND ' . $dpt_buffer;
         } else {
             $extra['where'] = $buffer . ' AND ' . $dpt_buffer;
         }
     } else {
         // There are no allowed companies, so don't allow projects.
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND (contact_company IS NULL OR contact_company = \'\' OR contact_company = 0) ';
         } else {
             $extra['where'] = 'contact_company IS NULL OR contact_company = \'\' OR contact_company = 0';
         }
     }
     return parent::getAllowedRecords($uid, $fields, $orderby, $index, $extra);
 }
Пример #19
0
 protected function hook_postUpdate()
 {
     parent::hook_postUpdate();
     $q = $this->_query;
     /*
      * TODO: I don't like that we have to run an update immediately after the store
      *   but I don't have a better solution at the moment.
      *                                      ~ caseydk 2012 Aug 04
      */
     $q->addTable('events');
     $q->addUpdate('event_sequence', "event_sequence+1", false, true);
     $q->addUpdate('event_updated', "'" . $q->dbfnNowWithTZ() . "'", false, true);
     $q->addWhere('event_id = ' . (int) $this->event_id);
     $q->exec();
 }
Пример #20
0
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $this->company_id = (int) $this->company_id;
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->company_id && canEdit('companies', $this->company_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->company_id && canAdd('companies')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if ($stored) {
         $custom_fields = new w2p_Core_CustomFields('companies', 'addedit', $this->company_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->company_id);
         // Store Custom Fields
     }
     return $stored;
 }
Пример #21
0
 public function store()
 {
     $stored = false;
     if (strpos($this->link_url, ':') === false && strpos($this->link_url, "//") === false) {
         $this->link_url = 'http://' . $this->link_url;
     }
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     $q = $this->_getQuery();
     $this->link_date = $q->dbfnNowWithTZ();
     if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'edit', $this->{$this->_tbl_key})) {
         if ($msg = parent::store()) {
             $this->_error['store'] = $msg;
         } else {
             $stored = true;
         }
     }
     if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'add')) {
         if ($msg = parent::store()) {
             $this->_error['store'] = $msg;
         } else {
             $stored = true;
         }
     }
     return $stored;
 }
Пример #22
0
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     if (!$this->event_recurs) {
         $this->event_times_recuring = 0;
     } else {
         //If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date
         //so that the event starts recurring from the start day onwards n times after the start date for the period given
         //Meaning: The event end date day is useless as far as recurring events are concerned.
         $start_date = new w2p_Utilities_Date($this->event_start_date);
         $end_date = new w2p_Utilities_Date($this->event_end_date);
         $hour = $end_date->getHour();
         $minute = $end_date->getMinute();
         $end_date->setDate($start_date->getDate());
         $end_date->setHour($hour);
         $end_date->setMinute($minute);
         $this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL);
     }
     // ensure changes to check boxes and select lists are honoured
     $this->event_private = (int) $this->event_private;
     $this->event_type = (int) $this->event_type;
     $this->event_cwd = (int) $this->event_cwd;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     $this->event_start_date = $AppUI->convertToSystemTZ($this->event_start_date);
     $this->event_end_date = $AppUI->convertToSystemTZ($this->event_end_date);
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->event_id && $perms->checkModuleItem('events', 'edit', $this->event_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->event_id && $perms->checkModuleItem('events', 'add')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if ($stored) {
         // TODO:  I *really* don't like using the POST inside here..
         $this->updateAssigned(explode(',', $_POST['event_assigned']));
         $custom_fields = new w2p_Core_CustomFields('calendar', 'addedit', $this->event_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->event_id);
         // Store Custom Fields
     }
     return $stored;
 }
Пример #23
0
 public function delete()
 {
     global $helpdesk_available;
     $this->_error = array();
     if ($this->_perms->checkModuleItem($this->_tbl_module, 'delete', $this->{$this->_tbl_key})) {
         // remove the file from the file system
         if (!$this->deleteFile()) {
             $this->_error['file-delete'] = 'file-delete';
             return false;
         }
         if ($msg = parent::delete()) {
             return $msg;
         }
         // delete any index entries
         $q = $this->_query;
         $q->setDelete('files_index');
         $q->addQuery('*');
         $q->addWhere('file_id = ' . (int) $this->file_id);
         if (!$q->exec()) {
             $result = db_error();
             $this->_error['index-delete'] = $result;
             return $result;
         }
         if ($helpdesk_available && $this->file_helpdesk_item != 0) {
             $this->addHelpDeskTaskLog();
         }
         return true;
     }
     return false;
 }
Пример #24
0
 public function __construct()
 {
     parent::__construct('resources', 'resource_id');
 }
Пример #25
0
 public function getAllowedRecords($uid, $fields = '*', $orderby = '', $index = null, $extra = null)
 {
     global $AppUI;
     $oPrj = new CProject();
     $aPrjs = $oPrj->getAllowedRecords($uid, 'projects.project_id, project_name', '', null, null, 'projects');
     if (count($aPrjs)) {
         $buffer = '(task_project IN (' . implode(',', array_keys($aPrjs)) . '))';
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND ' . $buffer;
         } else {
             $extra['where'] = $buffer;
         }
     } else {
         // There are no allowed projects, so don't allow tasks.
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND 1 = 0 ';
         } else {
             $extra['where'] = '1 = 0';
         }
     }
     return parent::getAllowedRecords($uid, $fields, $orderby, $index, $extra);
 }
Пример #26
0
 public function canDelete($notUsed = null, $notUsed2 = null, $notUsed3 = null)
 {
     $tables[] = array('label' => 'Company Owner', 'name' => 'companies', 'idfield' => 'company_id', 'joinfield' => 'company_owner');
     $tables[] = array('label' => 'Department Owner', 'name' => 'departments', 'idfield' => 'dept_id', 'joinfield' => 'dept_owner');
     $tables[] = array('label' => 'Project Owner', 'name' => 'projects', 'idfield' => 'project_id', 'joinfield' => 'project_owner');
     $tables[] = array('label' => 'Project Creator', 'name' => 'projects', 'idfield' => 'project_id', 'joinfield' => 'project_creator');
     $tables[] = array('label' => 'Project Updator', 'name' => 'projects', 'idfield' => 'project_id', 'joinfield' => 'project_updator');
     $tables[] = array('label' => 'Task Owner', 'name' => 'tasks', 'idfield' => 'task_id', 'joinfield' => 'task_owner');
     $tables[] = array('label' => 'Task Creator', 'name' => 'tasks', 'idfield' => 'task_id', 'joinfield' => 'task_creator');
     $tables[] = array('label' => 'Task Updator', 'name' => 'tasks', 'idfield' => 'task_id', 'joinfield' => 'task_updator');
     $tables[] = array('label' => 'Task Assignee', 'name' => 'user_tasks', 'idfield' => 'task_id', 'joinfield' => 'user_id');
     $tables[] = array('label' => 'Event Owner', 'name' => 'events', 'idfield' => 'event_id', 'joinfield' => 'event_owner');
     $tables[] = array('label' => 'Event Attendee', 'name' => 'user_events', 'idfield' => 'event_id', 'joinfield' => 'user_id');
     $tables[] = array('label' => 'File Owner', 'name' => 'files', 'idfield' => 'file_id', 'joinfield' => 'file_owner');
     $tables[] = array('label' => 'Forum Owner', 'name' => 'forums', 'idfield' => 'forum_id', 'joinfield' => 'forum_owner');
     $tables[] = array('label' => 'Forum Moderator', 'name' => 'forums', 'idfield' => 'forum_id', 'joinfield' => 'forum_moderated');
     $tables[] = array('label' => 'Forum Message Author', 'name' => 'forum_messages', 'idfield' => 'message_id', 'joinfield' => 'message_author');
     $tables[] = array('label' => 'Forum Message Editor', 'name' => 'forum_messages', 'idfield' => 'message_id', 'joinfield' => 'message_editor');
     $tables[] = array('label' => 'Link Owner', 'name' => 'links', 'idfield' => 'link_id', 'joinfield' => 'link_owner');
     return parent::canDelete('', null, $tables);
 }
Пример #27
0
 public function getAllowedRecords($uid, $fields = '*', $orderby = '', $index = null, $extra = null)
 {
     $oPrj = new CProject();
     $oPrj->overrideDatabase($this->_query);
     $aPrjs = $oPrj->getAllowedRecords($uid, 'projects.project_id, project_name', '', null, null, 'projects');
     if (count($aPrjs)) {
         $buffer = '(forum_project IN (' . implode(',', array_keys($aPrjs)) . ') OR forum_project IS NULL OR forum_project = \'\' OR forum_project = 0)';
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND ' . $buffer;
         } else {
             $extra['where'] = $buffer;
         }
     } else {
         // There are no allowed projects, so only allow forums with no project associated.
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND (forum_project IS NULL OR forum_project = \'\' OR forum_project = 0) ';
         } else {
             $extra['where'] = '(forum_project IS NULL OR forum_project = \'\' OR forum_project = 0)';
         }
     }
     return parent::getAllowedRecords($uid, $fields, $orderby, $index, $extra);
 }
Пример #28
0
 protected function hook_postStore()
 {
     $q = $this->_getQuery();
     //split out related departments and store them seperatly.
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     $stored_departments = array();
     if ($this->project_departments) {
         foreach ($this->project_departments as $department) {
             if ($department) {
                 $q->addTable('project_departments');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('department_id', $department);
                 $stored_departments[$department] = $this->project_id;
                 $q->exec();
                 $q->clear();
             }
         }
     }
     $this->stored_departments = $stored_departments;
     //split out related contacts and store them seperatly.
     $q->setDelete('project_contacts');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     $stored_contacts = array();
     if ($this->project_contacts) {
         foreach ($this->project_contacts as $contact) {
             if ($contact) {
                 $q->addTable('project_contacts');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('contact_id', $contact);
                 $stored_contacts[$contact] = $this->project_id;
                 $q->exec();
                 $q->clear();
             }
         }
     }
     $this->stored_contacts = $stored_contacts;
     CTask::storeTokenTask($this->_AppUI, $this->project_id);
     parent::hook_postStore();
 }
Пример #29
0
 public function delete(CAppUI $AppUI = null)
 {
     global $AppUI;
     global $helpdesk_available;
     $perms = $AppUI->acl();
     $this->_error = array();
     if ($perms->checkModuleItem('files', 'delete', $this->file_id)) {
         // remove the file from the file system
         if (!$this->deleteFile($AppUI)) {
             return false;
         }
         if ($msg = parent::delete()) {
             return $msg;
         }
         // delete any index entries
         $q = new w2p_Database_Query();
         $q->setDelete('files_index');
         $q->addQuery('*');
         $q->addWhere('file_id = ' . (int) $this->file_id);
         if (!$q->exec()) {
             $q->clear();
             return db_error();
         }
         if ($helpdesk_available && $this->file_helpdesk_item != 0) {
             $this->addHelpDeskTaskLog();
         }
         return true;
     }
     return false;
 }
Пример #30
0
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $stored = false;
     $this->_error = array();
     $q = $this->_query;
     $q->addQuery('billingcode_id');
     $q->addTable('billingcode');
     $q->addWhere('billingcode_name = \'' . $this->billingcode_name . '\'');
     $q->addWhere('company_id = ' . (int) $this->company_id);
     $found_id = $q->loadResult();
     $q->clear();
     if ($found_id && $found_id != $this->_billingcode_id) {
         return 'Billing Code::code already exists';
     } else {
         if ($perms->checkModuleItem('system', 'edit')) {
             if ($msg = parent::store()) {
                 return $msg;
             }
             $stored = true;
         }
     }
     return $stored;
 }