本文整理汇总了PHP中CTask::overrideDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP CTask::overrideDatabase方法的具体用法?PHP CTask::overrideDatabase怎么用?PHP CTask::overrideDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTask
的用法示例。
在下文中一共展示了CTask::overrideDatabase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProjectTaskLinksByCategory
public function getProjectTaskLinksByCategory($AppUI = null, $project_id = 0, $task_id = 0, $category_id = 0, $search = '')
{
// load the following classes to retrieved denied records
$project = new CProject();
$project->overrideDatabase($this->_query);
$task = new CTask();
$task->overrideDatabase($this->_query);
// SETUP FOR LINK LIST
$q = $this->_getQuery();
$q->addQuery('DISTINCT links.*');
$q->addQuery('contact_first_name, contact_last_name, contact_display_name as contact_name');
$q->addQuery('project_name, project_color_identifier, project_status');
$q->addQuery('task_name, task_id');
$q->addTable('links');
$q->leftJoin('users', 'u', 'user_id = link_owner');
$q->leftJoin('contacts', 'c', 'user_contact = contact_id');
if ($search != '') {
$q->addWhere('(link_name LIKE \'%' . $search . '%\' OR link_description LIKE \'%' . $search . '%\')');
}
if ($project_id > 0) {
// Project
$q->addWhere('link_project = ' . (int) $project_id);
}
if ($task_id > 0) {
// Task
$q->addWhere('link_task = ' . (int) $task_id);
}
if ($category_id >= 0) {
// Category
$q->addWhere('link_category = ' . $category_id);
}
// Permissions
$project->setAllowedSQL($this->_AppUI->user_id, $q, 'link_project');
$task->setAllowedSQL($this->_AppUI->user_id, $q, 'link_task and task_project = link_project');
$q->addOrder('project_name, link_name');
return $q->loadList();
}
示例2: getFileCountByFolder
public function getFileCountByFolder($notUsed = null, $folder_id, $task_id, $project_id, $company_id, $allowed_companies)
{
// SQL text for count the total recs from the selected option
$q = $this->_getQuery();
$q->addTable('files');
$q->addQuery('count(files.file_id)');
$q->addJoin('projects', 'p', 'p.project_id = file_project');
$q->addJoin('users', 'u', 'u.user_id = file_owner');
$q->addJoin('tasks', 't', 't.task_id = file_task');
$q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder');
$q->addWhere('file_folder = ' . (int) $folder_id);
//TODO: apply permissions properly
$project = new CProject();
$project->overrideDatabase($this->_query);
$deny1 = $project->getDeniedRecords($this->_AppUI->user_id);
if (count($deny1) > 0) {
$q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')');
}
//TODO: apply permissions properly
$task = new CTask();
$task->overrideDatabase($this->_query);
$deny2 = $task->getDeniedRecords($this->_AppUI->user_id);
if (count($deny2) > 0) {
$q->addWhere('file_task NOT IN (' . implode(',', $deny2) . ')');
}
if ($project_id) {
$q->addWhere('file_project = ' . (int) $project_id);
}
if ($task_id) {
$q->addWhere('file_task = ' . (int) $task_id);
}
if ($company_id) {
$q->innerJoin('companies', 'co', 'co.company_id = p.project_company');
$q->addWhere('company_id = ' . (int) $company_id);
$q->addWhere('company_id IN (' . $allowed_companies . ')');
}
$q->addGroup('file_folder_name');
$q->addGroup('project_name');
$q->addGroup('file_name');
// counts total recs from selection
return count($q->loadList());
}
示例3: getAllowedRecords
/**
* 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);
}
示例4: hasTasks
/**
* @deprecated
*/
public static function hasTasks($projectId, $override = null)
{
trigger_error("CProject::hasTasks() has been deprecated in v3.0 and will be removed in v4.0. Please use CTask->getTaskCount() instead.", E_USER_NOTICE);
$task = new CTask();
$task->overrideDatabase($override);
return $task->getTaskCount($projectId);
}
示例5: getDeepChildren
public function getDeepChildren()
{
$children = $this->getChildren();
if ($children) {
$deep_children = array();
$tempTask = new CTask();
$tempTask->overrideDatabase($this->_query);
foreach ($children as $child) {
$tempTask->load($child);
$deep_children = array_merge($deep_children, $tempTask->getDeepChildren());
}
return array_merge($children, $deep_children);
}
return array();
}
示例6: importTasks
/**
* Import tasks from another project
*
* @param int Project ID of the tasks come from.
* @return bool
* */
public function importTasks($from_project_id)
{
$errors = array();
// Load the original
$origProject = new CProject();
$origProject->overrideDatabase($this->_query);
$origProject->load($from_project_id);
$q = $this->_getQuery();
$q->addTable('tasks');
$q->addQuery('task_id');
$q->addWhere('task_project =' . (int) $from_project_id);
$tasks = array_flip($q->loadColumn());
$q->clear();
$origDate = new w2p_Utilities_Date($origProject->project_start_date);
$destDate = new w2p_Utilities_Date($this->project_start_date);
$timeOffset = $origDate->dateDiff($destDate);
if ($origDate->compare($origDate, $destDate) > 0) {
$timeOffset = -1 * $timeOffset;
}
// Dependencies array
$deps = array();
$objTask = new CTask();
$objTask->overrideDatabase($this->_query);
// Copy each task into this project and get their deps
$objTask = new CTask();
$objTask->overrideDatabase($this->_query);
foreach ($tasks as $orig => $void) {
$objTask->load($orig);
$destTask = $objTask->copy($this->project_id);
$destTask->task_parent = 0 == $destTask->task_parent ? $destTask->task_id : $destTask->task_parent;
$destTask->store();
$tasks[$orig] = $destTask;
$deps[$orig] = $objTask->getDependencies();
}
// Fix record integrity
foreach ($tasks as $old_id => $newTask) {
// Fix parent Task
// This task had a parent task, adjust it to new parent task_id
if ($newTask->task_id != $newTask->task_parent) {
$newTask->task_parent = $tasks[$newTask->task_parent]->task_id;
}
// Fix task start date from project start date offset
$origDate->setDate($newTask->task_start_date);
$origDate->addDays($timeOffset);
$destDate = $origDate;
$newTask->task_start_date = $destDate->format(FMT_DATETIME_MYSQL);
// Fix task end date from start date + work duration
if (!empty($newTask->task_end_date) && $newTask->task_end_date != '0000-00-00 00:00:00') {
$origDate->setDate($newTask->task_end_date);
$origDate->addDays($timeOffset);
$destDate = $origDate;
$newTask->task_end_date = $destDate->format(FMT_DATETIME_MYSQL);
}
// Dependencies
if (!empty($deps[$old_id])) {
$oldDeps = explode(',', $deps[$old_id]);
// New dependencies array
$newDeps = array();
foreach ($oldDeps as $dep) {
$newDeps[] = $tasks[$dep]->task_id;
}
// Update the new task dependencies
$csList = implode(',', $newDeps);
$newTask->updateDependencies($csList);
}
// end of update dependencies
$result = $newTask->store();
$newTask->addReminder();
$importedTasks[] = $newTask->task_id;
if (is_array($result) && count($result)) {
foreach ($result as $key => $error_msg) {
$errors[] = $newTask->task_name . ': ' . $error_msg;
}
}
}
// end Fix record integrity
// We have errors, so rollback everything we've done so far
if (count($errors)) {
$delTask = new CTask();
$delTask->overrideDatabase($this->_query);
foreach ($importedTasks as $badTask) {
$delTask->task_id = $badTask;
$delTask->delete();
}
}
return $errors;
}