Exemple #1
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;
 }
Exemple #2
0
 public function __construct()
 {
     parent::__construct('file_folders', 'file_folder_id');
 }
Exemple #3
0
 public function getAllowedRecords($uid, $fields = '*', $orderby = '', $index = null, $extra = null)
 {
     global $AppUI;
     $oTsk = new CTask();
     $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);
 }
Exemple #4
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 = '(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);
 }
Exemple #5
0
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     $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 && $perms->checkModuleItem('companies', 'edit', $this->company_id)) {
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('companies', $this->company_id, 'update', $this->company_name, $this->company_id);
         $stored = true;
     }
     if (0 == $this->company_id && $perms->checkModuleItem('companies', 'add')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('companies', $this->company_id, 'add', $this->company_name, $this->company_id);
         $stored = true;
     }
     if ($stored) {
         $custom_fields = new CustomFields('companies', 'addedit', $this->company_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->company_id);
         // Store Custom Fields
     }
     return $stored;
 }
Exemple #6
0
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     if ($this->link_id && $perms->checkModuleItem('links', 'edit', $this->link_id)) {
         $q = new DBQuery();
         $this->link_date = $q->dbfnNow();
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('links', $this->link_id, 'update', $this->link_name, $this->link_id);
         $stored = true;
     }
     if (0 == $this->link_id && $perms->checkModuleItem('links', 'add')) {
         $q = new DBQuery();
         $this->link_date = $q->dbfnNow();
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('links', $this->link_id, 'add', $this->link_name, $this->link_id);
         $stored = true;
     }
     return $stored;
 }
 public function __construct()
 {
     parent::__construct('project_designer_options', 'pd_option_id');
 }
Exemple #8
0
 public function __construct()
 {
     parent::__construct('billingcode', 'billingcode_id');
 }
Exemple #9
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);
 }
Exemple #10
0
 public function delete($oid = null)
 {
     global $AppUI;
     $id = (int) $this->user_id;
     //check if the user is related to anything and disallow deletion if he is.
     //companies: is he a owner of any company?
     $q = new DBQuery();
     $q->addQuery('count(company_id)');
     $q->addTable('companies');
     $q->addWhere('company_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Companies') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //departments: is he a owner of any department?
     $q = new DBQuery();
     $q->addQuery('count(dept_id)');
     $q->addTable('departments');
     $q->addWhere('dept_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Departments') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //events: is he a owner of any event?
     $q = new DBQuery();
     $q->addQuery('count(event_id)');
     $q->addTable('events');
     $q->addWhere('event_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Events') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //files: is he a owner of any file?
     $q = new DBQuery();
     $q->addQuery('count(file_id)');
     $q->addTable('files');
     $q->addWhere('file_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Files') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //forums: is he a owner of any forum?
     $q = new DBQuery();
     $q->addQuery('count(forum_id)');
     $q->addTable('forums');
     $q->addWhere('forum_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Forums') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //forums: is he a moderator of any forum?
     $q = new DBQuery();
     $q->addQuery('count(forum_id)');
     $q->addTable('forums');
     $q->addWhere('forum_moderated = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Forums') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Forum Moderator') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //forums: is he a message creator on any forum?
     $q = new DBQuery();
     $q->addQuery('count(message_id)');
     $q->addTable('forum_messages');
     $q->addWhere('message_author = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Forum Messages') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Author') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //forums: is he a message creator on any forum?
     $q = new DBQuery();
     $q->addQuery('count(message_id)');
     $q->addTable('forum_messages');
     $q->addWhere('message_editor = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Forum Messages') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Editor') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //links: is he a owner of any link?
     $q = new DBQuery();
     $q->addQuery('count(link_id)');
     $q->addTable('links');
     $q->addWhere('link_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Links') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //projects: is he related to any project?
     $q = new DBQuery();
     $q->addQuery('count(project_id)');
     $q->addTable('projects');
     $q->addWhere('(project_owner = ' . $id . ' OR project_creator = ' . $id . ' OR project_updator = ' . $id . ')');
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Projects') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner, Creator or Updator') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //tasks: is he related to any task?
     $q = new DBQuery();
     $q->addQuery('count(task_id)');
     $q->addTable('tasks');
     $q->addWhere('(task_owner = ' . $id . ' OR task_creator = ' . $id . ' OR task_updator = ' . $id . ')');
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Tasks') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner, Creator or Updator') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //events: is he related to any event?
     $q = new DBQuery();
     $q->addQuery('count(event_id)');
     $q->addTable('user_events');
     $q->addWhere('user_id = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Events') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Attendee') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //tasks: is he related to any event?
     $q = new DBQuery();
     $q->addQuery('count(task_id)');
     $q->addTable('user_tasks');
     $q->addWhere('user_id = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Tasks') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Assignee') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //tasks: is he related to any pins?
     $q = new DBQuery();
     $q->addQuery('count(task_id)');
     $q->addTable('user_task_pin');
     $q->addWhere('user_id = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Tasks') . ' ' . $AppUI->_('pinned') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     $result = parent::delete($oid);
     if (!$result) {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->deleteLogin($id);
         $q = new DBQuery();
         $q->setDelete('user_preferences');
         $q->addWhere('pref_user = ' . $id);
         $q->exec();
         $q->clear();
     }
     return $result;
 }
Exemple #11
0
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $stored = false;
     $this->w2PTrimAll();
     $this->project_target_budget = str_replace(',', '', $this->project_target_budget);
     // 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 = $this->project_target_budget ? $this->project_target_budget : 0.0;
     $this->project_actual_budget = $this->project_actual_budget ? $this->project_actual_budget : 0.0;
     // Make sure project_short_name is the right size (issue for languages with encoded characters)
     if (mb_strlen($this->project_short_name) > 10) {
         $this->project_short_name = mb_substr($this->project_short_name, 0, 10);
     }
     if (empty($this->project_end_date)) {
         $this->project_end_date = null;
     }
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     $this->project_id = (int) $this->project_id;
     // convert dates to SQL format first
     if ($this->project_start_date) {
         $date = new CDate($this->project_start_date);
         $this->project_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_end_date) {
         $date = new CDate($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 CDate($this->project_actual_end_date);
         $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     // let's check if there are some assigned departments to project
     if ('' != $this->project_actual_end_date) {
         $obj->project_departments = implode(',', w2PgetParam($_POST, 'dept_ids', array()));
     }
     // 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...
      */
     if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->company_id)) {
         $q = new DBQuery();
         $this->project_updated = $q->dbfnNow();
         if ($msg = parent::store()) {
             return $msg;
         }
         addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id);
         $stored = true;
     }
     if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) {
         $q = new DBQuery();
         $this->project_updated = $q->dbfnNow();
         $this->project_created = $q->dbfnNow();
         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;
             }
         }
         addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id);
         $stored = true;
     }
     //split out related departments and store them seperatly.
     $q = new DBQuery();
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . (int) $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_departments) {
         $departments = explode(',', $this->project_departments);
         foreach ($departments as $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) {
         $contacts = explode(',', $this->project_contacts);
         foreach ($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 CustomFields('projects', 'addedit', $this->project_id, 'edit');
         $custom_fields->bind($_POST);
         $sql = $custom_fields->store($this->project_id);
         // Store Custom Fields
     }
     return $stored;
 }
Exemple #12
0
 public function CResource()
 {
     parent::__construct('resources', 'resource_id');
 }
Exemple #13
0
 public function __construct()
 {
     parent::__construct('history', 'history_id');
 }
 public function __construct()
 {
     parent::__construct('departments', 'dept_id');
 }