示例#1
0
 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;
 }
 function canDelete(&$msg, $oid = null)
 {
     $tables[] = array('label' => 'Projects', 'name' => 'projects', 'idfield' => 'project_id', 'joinfield' => 'project_company');
     $tables[] = array('label' => 'Departments', 'name' => 'departments', 'idfield' => 'dept_id', 'joinfield' => 'dept_company');
     $tables[] = array('label' => 'Users', 'name' => 'users', 'idfield' => 'user_id', 'joinfield' => 'user_company');
     // call the parent class method to assign the oid
     return CDpObject::canDelete($msg, $oid, $tables);
 }
示例#3
0
 function store()
 {
     global $helpdesk_available;
     if ($helpdesk_available && $this->file_helpdesk_item != 0) {
         $this->addHelpDeskTaskLog();
     }
     parent::store();
 }
示例#4
0
 function delete($oid = NULL)
 {
     $id = $this->user_id;
     $result = parent::delete($oid);
     if (!$result) {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->deleteLogin($id);
         $q = new DBQuery();
         $q->setDelete('user_preferences');
         $q->addWhere('pref_user = ' . $this->user_id);
         $q->exec();
         $q->clear();
     }
     return $result;
 }
示例#5
0
 function canDelete(&$msg, $oid = null, $joins = null)
 {
     global $AppUI;
     if ($oid) {
         // Check to see if there is a user
         $q = new DBQuery();
         $q->addTable('users');
         $q->addQuery('count(*) as user_count');
         $q->addWhere('user_contact = ' . (int) $oid);
         $user_count = $q->loadResult();
         if ($user_count > 0) {
             $msg = $AppUI->_('contactsDeleteUserError');
             return false;
         }
     }
     return parent::canDelete($msg, $oid, $joins);
 }
示例#6
0
 /**
  *	Overload of the dpObject::getDeniedRecords
  *	to ensure that the projects owned by denied companies are denied.
  *
  *	@author	handco <*****@*****.**>
  *	@see	dpObject::getAllowedRecords
  */
 function getDeniedRecords($uid)
 {
     $aBuf1 = parent::getDeniedRecords($uid);
     $oCpy = new CCompany();
     // Retrieve which projects are allowed due to the company rules
     $aCpiesAllowed = $oCpy->getAllowedRecords($uid, 'company_id,company_name');
     $q = new DBQuery();
     $q->addTable('projects');
     $q->addQuery('project_id');
     if (count($aCpiesAllowed)) {
         $q->addWhere('NOT (project_company IN (' . implode(',', array_keys($aCpiesAllowed)) . '))');
     }
     $sql = $q->prepare();
     $q->clear();
     $aBuf2 = db_loadColumn($sql);
     return array_merge($aBuf1, $aBuf2);
 }
示例#7
0
 function canDelete(&$msg, $oid = null, $joins = null)
 {
     global $AppUI;
     $oid = intval($oid ? $oid : $this->file_folder_id);
     if (!parent::canDelete($msg, $oid, $joins)) {
         return false;
     }
     $this->_query->clear();
     $this->_query->addTable($this->_tbl);
     $this->_query->addQuery('COUNT(DISTINCT file_folder_id) AS num_of_subfolders');
     $this->_query->addWhere('file_folder_parent=' . $oid);
     $sql1 = $this->_query->prepare();
     $this->_query->clear();
     $this->_query->addTable('files');
     $this->_query->addQuery('COUNT(DISTINCT file_id) AS num_of_files');
     $this->_query->addWhere('file_folder=' . $oid);
     $sql2 = $this->_query->prepare();
     $this->_query->clear();
     if (db_loadResult($sql1) > 0 || db_loadResult($sql2) > 0) {
         $msg = $AppUI->_('Can not delete folder, it has files and/or subfolders.');
         return false;
     }
     return true;
 }
示例#8
0
 function CForum()
 {
     // empty constructor
     parent::CDpObject('forums', 'forum_id');
 }
 function CProjectsStatistics()
 {
     parent::CDpObject('projects_statistics', 'projects_statistics_id');
 }
示例#10
0
 function store()
 {
     $msg = $this->check();
     return $msg ? $msg : parent::store();
 }
示例#11
0
 function CResource()
 {
     parent::CDpObject('resources', 'resource_id');
 }
示例#12
0
 function delete($oid = NULL)
 {
     $id = $this->user_id;
     $result = parent::delete($oid);
     if (!$result) {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->deleteLogin($id);
     }
     return $result;
 }
示例#13
0
 function load($oid = null, $strip = false)
 {
     // use parent function to load the given object
     $loaded = parent::load($oid, $strip);
     /*
      ** Update the values of a dynamic task from
      ** the children's properties each time the
      ** dynamic task is loaded.
      ** Additionally store the values in the db.
      ** Only treat umbrella tasks of dynamics '1'.
      */
     if ($this->task_dynamic == '1') {
         // update task from children
         $this->updateDynamics(true);
         /*
          ** Use parent function to store the updated values in the db
          ** instead of store function of this object in order to
          ** prevent from infinite loops.
          */
         parent::store();
     }
     // return whether the object load process has been successful or not
     return $loaded;
 }
示例#14
0
 function __construct()
 {
     parent::__construct('billingcode', 'billingcode_id');
     $this->_module_directory = 'system';
 }
示例#15
0
 function dPTrimAll()
 {
     $spacedDescription = $this->task_log_description;
     parent::dPTrimAll();
     $this->task_log_description = $spacedDescription;
 }
 function _searchResults()
 {
     global $AppUI, $locale_char_set;
     $q = new DBQuery();
     $dPObj = new CDpObject($this->table, $this->table_key);
     $q->addTable($this->table, $this->table_alias);
     foreach ($this->table_joins as $join) {
         $q->addJoin($join['table'], $join['alias'], $join['join']);
     }
     $q->addQuery($this->table_key);
     if (isset($this->table_key2)) {
         $q->addQuery($this->table_key2);
     }
     foreach ($this->display_fields as $fld) {
         $q->addQuery($fld);
     }
     $q->addOrder($this->table_orderby);
     $dPObj->setAllowedSQL($AppUI->user_id, $q, null, null, $this->table_module);
     if ($this->table_extra) {
         $q->addWhere($this->table_extra);
     }
     $keys = '';
     $keys2 = '';
     foreach (array_keys($this->keywords) as $keyword) {
         if ($keys2) {
             $keys .= $this->search_options['all_words'] == 'on' ? ' AND ' : ' OR ';
             $keys2 = '';
         }
         foreach ($this->search_fields as $field) {
             // OR treatment to each keyword
             // Search for semi-colons, commas or spaces and allow any to be separators
             $or_keywords = preg_split('/[\\s,;]+/', $keyword);
             foreach ($or_keywords as $or_keyword) {
                 $search_pattern = $this->search_options['ignore_specchar'] == 'on' ? recode2regexp_utf8($or_keyword) : '(' . $or_keyword . ')';
                 $keys2 .= $keys2 ? ' OR ' : '';
                 $keys2 .= '(' . $field . ' REGEXP ' . ($this->search_options['ignore_case'] == 'on' ? '' : ' BINARY ') . "'.*" . $search_pattern . ".*'" . ($this->search_options['ignore_specchar'] == 'on' ? ' COLLATE utf8_general_ci' : '') . ')';
             }
         }
         $keys .= $keys2 ? '(' . $keys2 . ')' : '';
     }
     if ($keys) {
         $q->addWhere($keys);
     }
     $results = $q->loadList();
     return $results;
 }
示例#17
0
 /**
  *	Overloaded delete method
  *
  *	@author gregorerhardt
  *	@return null|string null if successful otherwise returns and error message
  */
 function delete()
 {
     global $AppUI;
     // call default delete method first
     $deleted = parent::delete($this->event_id);
     // if object deletion succeeded then iteratively delete relationships
     if (empty($deleted)) {
         // delete user_events relationship
         $q = new DBQuery();
         $q->setDelete('user_events');
         $q->addWhere('event_id = ' . $this->event_id);
         $deleted = !$q->exec() ? $AppUI->_('Could not delete Event-User relationship') . '. ' . db_error() : null;
         $q->clear;
     }
     return $deleted;
 }
示例#18
0
 function store()
 {
     global $AppUI;
     // Update the last modified time and user
     $this->item_modified = db_unix2dateTime(time());
     $this->item_summary = strip_tags($this->item_summary);
     //if type indicates a contact or a user, then look up that phone and email
     //for those entries
     switch ($this->item_requestor_type) {
         case '0':
             //it's not a user or a contact
             break;
         case '1':
             //it's a system user
             $sql = "SELECT user_id as id,\n                       contact_email as email,\n                       contact_phone as phone,\n                CONCAT(contact_first_name,' ', contact_last_name) as name\n                FROM users\n               LEFT JOIN contacts ON user_contact = contact_id\n                WHERE user_id='{$this->item_requestor_id}'";
             break;
         case '2':
             $sql = "SELECT contact_id as id,\n                       contact_email as email,\n                       contact_phone as phone,\n                CONCAT(contact_first_name,' ', contact_last_name) as name\n                FROM contacts\n                WHERE contact_id='{$this->item_requestor_id}'";
             break;
         default:
             break;
     }
     if (isset($sql)) {
         db_loadHash($sql, $result);
         $this->item_requestor_email = $result['email'];
         $this->item_requestor_phone = $result['phone'];
         $this->item_requestor = $result['name'];
     }
     /* if the store is successful, pull the new id value and insert it into the 
        object. */
     if ($msg = parent::store()) {
         return $msg;
     } else {
         if (!$this->item_id) {
             $this->item_id = mysql_insert_id();
         }
         return $msg;
     }
 }
示例#19
0
 function __construct()
 {
     parent::__construct('links', 'link_id');
 }
示例#20
0
 function store()
 {
     global $AppUI;
     // Update the last modified time and user
     //$this->item_created = new CDate();
     $this->item_summary = strip_tags($this->item_summary);
     //if type indicates a contact or a user, then look up that phone and email
     //for those entries
     switch ($this->item_requestor_type) {
         case '0':
             //it's not a user or a contact
             break;
         case '1':
             //it's a system user
             $q = new DBQuery();
             $q->addTable('users', 'u');
             $q->addQuery('u.user_id as id');
             $q->addJoin('contacts', 'c', 'u.user_contact = c.contact_id');
             $q->addQuery("c.contact_email as email, c.contact_phone as phone, CONCAT(c.contact_first_name,' ', c.contact_last_name) as name");
             /*        $sql = "SELECT user_id as id,
                               contact_email as email,
                               contact_phone as phone,
                        CONCAT(contact_first_name,' ', contact_last_name) as name
                        FROM users
                       LEFT JOIN contacts ON user_contact = contact_id
                        WHERE user_id='{$this->item_requestor_id}'";*/
             break;
         case '2':
             $q = new DBQuery();
             $q->addTable('contacts', 'c');
             $q->addQuery("c.contact_email as email, c.contact_phone as phone, CONCAT(c.contact_first_name,' ', c.contact_last_name) as name");
             $q->addWhere('contact_id=' . $this->item_requestor_id);
             /*        $sql = "SELECT contact_id as id,
                              contact_email as email,
                              contact_phone as phone,
                       CONCAT(contact_first_name,' ', contact_last_name) as name
                       FROM contacts
                       WHERE contact_id='{$this->item_requestor_id}'";*/
             break;
         default:
             break;
     }
     if (isset($q)) {
         $result = $q->loadHash();
         $q->clear();
         $this->item_requestor_email = $result['email'];
         $this->item_requestor_phone = $result['phone'];
         $this->item_requestor = $result['name'];
     }
     /* if the store is successful, pull the new id value and insert it into the 
        object. */
     if ($msg = parent::store()) {
         return $msg;
     } else {
         if (!$this->item_id) {
             $this->item_id = mysql_insert_id();
         }
         return $msg;
     }
 }