/** ** 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); }
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); }
/** ** 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, $table_alias = '') { $oCpy = new CCompany(); $aCpies = $oCpy->getAllowedRecords($uid, 'company_id, company_name'); if (count($aCpies)) { $buffer = '(project_company IN (' . implode(',', array_keys($aCpies)) . '))'; if (!isset($extra['from']) && !isset($extra['join'])) { $extra['join'] = 'project_departments'; $extra['on'] = 'projects.project_id = project_departments.project_id'; } elseif ($extra['from'] != 'project_departments' && !isset($extra['join'])) { $extra['join'] = 'project_departments'; $extra['on'] = 'projects.project_id = project_departments.project_id'; } //Department permissions $oDpt = new CDepartment(); $aDpts = $oDpt->getAllowedRecords($uid, 'dept_id, dept_name'); if (count($aDpts)) { $dpt_buffer = '(department_id IN (' . implode(',', array_keys($aDpts)) . ') OR department_id IS NULL)'; } else { // There are no allowed departments, so allow projects with no department. $dpt_buffer = '(department_id IS NULL)'; } if (isset($extra['where']) && $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 1 = 0 '; } else { $extra['where'] = '1 = 0'; } } return parent::getAllowedRecords($uid, $fields, $orderby, $index, $extra, $table_alias); }
/** * 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); }
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 = '(event_project IN (' . implode(',', array_keys($aPrjs)) . ') OR event_project IS NULL OR event_project = \'\' OR event_project = 0)'; if ($extra['where'] != '') { $extra['where'] = $extra['where'] . ' AND ' . $buffer; } else { $extra['where'] = $buffer; } } else { // There are no allowed projects, so only allow events with no project. if ($extra['where'] != '') { $extra['where'] = $extra['where'] . ' AND (event_project IS NULL OR event_project = \'\' OR event_project = 0) '; } else { $extra['where'] = '(event_project IS NULL OR event_project = \'\' OR event_project = 0)'; } } return parent::getAllowedRecords($uid, $fields, $orderby, $index, $extra); }
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); }