本文整理汇总了PHP中CProject::setAllowedSQL方法的典型用法代码示例。如果您正苦于以下问题:PHP CProject::setAllowedSQL方法的具体用法?PHP CProject::setAllowedSQL怎么用?PHP CProject::setAllowedSQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CProject
的用法示例。
在下文中一共展示了CProject::setAllowedSQL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProjectTaskLinksByCategory
public function getProjectTaskLinksByCategory($AppUI, $project_id = 0, $task_id = 0, $category_id = 0, $search = '')
{
// load the following classes to retrieved denied records
$project = new CProject();
$task = new CTask();
// SETUP FOR LINK LIST
$q = new DBQuery();
$q->addQuery('links.*');
$q->addQuery('contact_first_name, contact_last_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($AppUI->user_id, $q, 'link_project');
$task->setAllowedSQL($AppUI->user_id, $q, 'link_task and task_project = link_project');
$q->addOrder('project_name, link_name');
return $q->loadList();
}
示例2: getAllowedForums
public function getAllowedForums($user_id, $company_id, $filter = -1, $orderby = 'forum_name', $orderdir = 'asc', $max_msg_length = 30)
{
$project = new CProject();
$project->overrideDatabase($this->_query);
$q = $this->_getQuery();
$q->addTable('forums');
$q->addQuery('forum_id, forum_project, forum_description, forum_owner, forum_name');
$q->addQuery('forum_moderated, forum_create_date, forum_last_date');
$q->addQuery('sum(if(c.message_parent=-1,1,0)) as forum_topics, sum(if(c.message_parent>0,1,0)) as forum_replies');
$q->addQuery('user_username, project_name, project_color_identifier, contact_display_name as owner_name, user_id');
$q->addQuery('SUBSTRING(l.message_body,1,' . $max_msg_length . ') message_body');
$q->addQuery('LENGTH(l.message_body) message_length, watch_user, l.message_parent, l.message_id');
$q->addQuery('count(distinct v.visit_message) as visit_count, count(distinct c.message_id) as message_count');
$q->addJoin('users', 'u', 'u.user_id = forum_owner');
$q->addJoin('projects', 'pr', 'pr.project_id = forum_project');
$q->addJoin('forum_messages', 'l', 'l.message_id = forum_last_id');
$q->addJoin('forum_messages', 'c', 'c.message_forum = forum_id');
$q->addJoin('forum_watch', 'w', 'watch_user = ' . $user_id . ' AND watch_forum = forum_id');
$q->addJoin('forum_visits', 'v', 'visit_user = ' . $user_id . ' AND visit_forum = forum_id and visit_message = c.message_id');
$q->addJoin('contacts', 'cts', 'contact_id = u.user_contact');
$q = $project->setAllowedSQL($user_id, $q, null, 'pr');
$q = $this->setAllowedSQL($user_id, $q);
switch ($filter) {
case 1:
$q->addWhere('forum_owner = ' . $user_id);
break;
case 2:
$q->addWhere('watch_user = ' . $user_id);
break;
case 3:
$q->addWhere('project_owner = ' . $user_id);
break;
case 4:
$q->addWhere('project_company = ' . $company_id);
break;
case 5:
$q->addWhere('(project_active = 0 OR forum_project = 0)');
break;
default:
$q->addWhere('(project_active = 1 OR forum_project = 0)');
break;
}
$q->addGroup('forum_id');
$orderby = property_exists($this, $orderby) ? $orderby : 'forum_name';
$q->addOrder($orderby . ' ' . $orderdir);
return $q->loadList();
}
示例3: getProjectTaskLinksByCategory
public function getProjectTaskLinksByCategory($notUsed = 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('links.*');
$q->addTable('links');
$q->leftJoin('projects', 'pr', 'project_id = link_project');
$q->leftJoin('tasks', 't', 'task_id = link_task');
if ($search != '') {
$q->addWhere('(link_name LIKE \'%' . $search . '%\' OR link_description LIKE \'%' . $search . '%\')');
}
if ($project_id > 0) {
// Project
$q->addQuery('project_name, project_color_identifier, project_status');
$q->addWhere('link_project = ' . (int) $project_id);
}
if ($task_id > 0) {
// Task
$q->addQuery('task_name, task_id');
$q->addWhere('link_task = ' . (int) $task_id);
}
if ($category_id >= 0) {
// Category
$q->addWhere('link_category = ' . $category_id);
}
// Permissions
$q = $project->setAllowedSQL($this->_AppUI->user_id, $q, 'link_project');
$q = $task->setAllowedSQL($this->_AppUI->user_id, $q, 'link_task and task_project = link_project');
$q->addOrder('project_name, link_name');
return $q->loadList();
}
示例4: getProjects
public static function getProjects($AppUI, $companyId, $active = 1, $sort = 'project_name')
{
$fields = 'pr.project_id, project_name, project_start_date, ' . 'project_status, project_target_budget, project_start_date, ' . 'project_priority, contact_first_name, contact_last_name';
$q = new DBQuery();
$q->addTable('projects', 'pr');
$q->addQuery($fields);
$q->leftJoin('users', 'u', 'u.user_id = pr.project_owner');
$q->leftJoin('contacts', 'con', 'u.user_contact = con.contact_id');
if ((int) $companyId > 0) {
$q->addWhere('pr.project_company = ' . (int) $companyId);
}
$projObj = new CProject();
$projObj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
$q->addWhere('pr.project_active = ' . (int) $active);
if (strpos($fields, $sort) !== false) {
$q->addOrder($sort);
}
return $q->loadList();
}
示例5: CProject
$query->clear();
$proj = new CProject();
$task = new CTask();
$ss = $start_date->format(FMT_DATETIME_MYSQL);
$se = $end_date->format(FMT_DATETIME_MYSQL);
$query->addTable('tasks', 't');
$query->leftJoin('projects', 'p', 'p.project_id = t.task_project');
$query->addQuery('t.*');
if ($use_period) {
$query->addWhere("((task_start_date >= '{$ss}' AND task_start_date <= '{$se}') " . " OR (task_end_date <= '{$se}' AND task_end_date >= '{$ss}'))");
}
if ($project_id) {
$query->addWhere('t.task_project = ' . $project_id);
}
// Now add the required restrictions.
$proj->setAllowedSQL($AppUI->user_id, $query, null, 'p');
$task->setAllowedSQL($AppUI->user_id, $query, null, 't');
$query->addOrder('task_end_date');
$task_list_hash = $query->loadHashList('task_id');
$query->clear();
$task_list = array();
$task_assigned_users = array();
foreach ($task_list_hash as $task_id => $task_data) {
$task = new CTask();
$task->bind($task_data);
$task_list[$task_id] = $task;
$task_assigned_users[$task_id] = $task->getAssignedUsers();
}
$user_usage = array();
$task_dates = array();
$actual_date = $start_date;
示例6: arrayMerge
foreach ($deptList as $dept) {
$department_selection_list[$dept['dept_id']] = $dept['dept_name'];
}
$department_selection_list = arrayMerge(array('0' => ''), $department_selection_list);
//Dynamic tasks are by default now off because of dangerous behavior if incorrectly used
if (is_null($task->task_dynamic)) {
$task->task_dynamic = 0;
}
$can_edit_time_information = $task->canUserEditTimeInformation();
//get list of projects, for task move drop down list.
$pq = new DBQuery();
$pq->addQuery('pr.project_id, project_name');
$pq->addTable('projects', 'pr');
$pq->addWhere('( project_active = 1 or pr.project_id = ' . (int) $task_project . ')');
$pq->addOrder('project_name');
$project->setAllowedSQL($AppUI->user_id, $pq, null, 'pr');
$projects = $pq->loadHashList();
?>
<script language="JavaScript">
var selected_contacts_id = '<?php
echo $task->task_contacts;
?>
';
var task_id = '<?php
echo $task->task_id;
?>
';
var check_task_dates = <?php
if (isset($w2Pconfig['check_task_dates']) && $w2Pconfig['check_task_dates']) {
echo 'true';
示例7: projects_list_data
//.........这里部分代码省略.........
$q->addTable('departments');
$q->addQuery('dept_id, dept_parent');
$q->addOrder('dept_parent,dept_name');
$rows = $q->loadList();
addDeptId($rows, $department);
$dept_ids[] = isset($department->dept_id) ? $department->dept_id : 0;
$dept_ids[] = $department > 0 ? $department : 0;
}
$q->clear();
// retrieve list of records
// modified for speed
// by Pablo Roca (pabloroca@mvps.org)
// 16 August 2003
// get the list of permitted companies
$obj = new CCompany();
$companies = $obj->getAllowedRecords($AppUI->user_id, 'companies.company_id,companies.company_name', 'companies.company_name');
if (count($companies) == 0) {
$companies = array();
}
$q->addTable('projects', 'pr');
$q->addQuery('pr.project_id, project_status, project_color_identifier,
project_type, project_name, project_description, project_scheduled_hours as project_duration,
project_parent, project_original_parent, project_percent_complete,
project_color_identifier, project_company,
company_name, project_status, project_last_task as critical_task,
tp.task_log_problem, user_username, project_active');
$fields = w2p_Core_Module::getSettings('projects', 'index_list');
unset($fields['department_list']);
// added as an alias below
foreach ($fields as $field => $text) {
$q->addQuery($field);
}
$q->addQuery('CONCAT(ct.contact_first_name, \' \', ct.contact_last_name) AS owner_name');
$q->addJoin('users', 'u', 'pr.project_owner = u.user_id');
$q->addJoin('contacts', 'ct', 'ct.contact_id = u.user_contact');
$q->addJoin('tasks_problems', 'tp', 'pr.project_id = tp.task_project');
if ($addProjectsWithAssignedTasks) {
$q->addJoin('tasks_users', 'tu', 'pr.project_id = tu.task_project');
}
if (!isset($department) && $company_id && !$addPwOiD) {
$q->addWhere('pr.project_company = ' . (int) $company_id);
}
if ($project_type > -1) {
$q->addWhere('pr.project_type = ' . (int) $project_type);
}
if (isset($department) && !$addPwOiD) {
$q->addWhere('project_departments.department_id in ( ' . implode(',', $dept_ids) . ' )');
}
if ($user_id && $addProjectsWithAssignedTasks) {
$q->addWhere('(tu.user_id = ' . (int) $user_id . ' OR pr.project_owner = ' . (int) $user_id . ' )');
} elseif ($user_id) {
$q->addWhere('pr.project_owner = ' . (int) $user_id);
}
if ($owner > 0) {
$q->addWhere('pr.project_owner = ' . (int) $owner);
}
if (mb_trim($search_text)) {
$q->addWhere('pr.project_name LIKE \'%' . $search_text . '%\' OR pr.project_description LIKE \'%' . $search_text . '%\'');
}
// Show Projects where the Project Owner is in the given department
if ($addPwOiD && !empty($owner_ids)) {
$q->addWhere('pr.project_owner IN (' . implode(',', $owner_ids) . ')');
}
$orderby = 'project_company' == $orderby ? 'company_name' : $orderby;
$q->addGroup('pr.project_id');
$q->addOrder($orderby . ' ' . $orderdir);
$prj = new CProject();
$prj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
$dpt = new CDepartment();
$projects = $q->loadList();
// get the list of permitted companies
$companies = arrayMerge(array('0' => $AppUI->_('All')), $companies);
$company_array = $companies;
//get list of all departments, filtered by the list of permitted companies.
$q->clear();
$q->addTable('companies');
$q->addQuery('company_id, company_name, dep.*');
$q->addJoin('departments', 'dep', 'companies.company_id = dep.dept_company');
$q->addOrder('company_name,dept_parent,dept_name');
$obj->setAllowedSQL($AppUI->user_id, $q);
$dpt->setAllowedSQL($AppUI->user_id, $q);
$rows = $q->loadList();
//display the select list
$buffer = '<select name="department" id="department" onChange="document.pickCompany.submit()" class="text" style="width: 200px;">';
$company = '';
foreach ($company_array as $key => $c_name) {
$buffer .= '<option value="' . $company_prefix . $key . '" style="font-weight:bold;"' . ($company_id == $key ? 'selected="selected"' : '') . '>' . $c_name . '</option>' . "\n";
foreach ($rows as $row) {
if ($row['dept_parent'] == 0) {
if ($key == $row['company_id']) {
if ($row['dept_parent'] != null) {
findchilddept($rows, $row['dept_id']);
}
}
}
}
}
$buffer .= '</select>';
return $projects;
}
示例8: max
// pull valid projects and their percent complete information
// GJB: Note that we have to special case duration type 24 and this refers to the hours in a day, NOT 24 hours
$q = new w2p_Database_Query();
$q->addTable('projects', 'pr');
$q->addQuery('DISTINCT pr.project_id, project_color_identifier, project_name, project_start_date, project_end_date,
max(t1.task_end_date) AS project_actual_end_date, project_percent_complete, project_status, project_active');
$q->addJoin('tasks', 't1', 'pr.project_id = t1.task_project');
$q->addJoin('companies', 'c1', 'pr.project_company = c1.company_id');
if ($department > 0) {
$q->addWhere('project_departments.department_id = ' . (int) $department);
}
if (!($department > 0) && $company_id != 0) {
$q->addWhere('project_company = ' . (int) $company_id);
}
$q->addWhere('project_original_parent = ' . (int) $original_project_id);
$pjobj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
$q->addGroup('pr.project_id');
$q->addOrder('project_start_date, project_end_date, project_name');
$projects = $q->loadHashList('project_id');
$q->clear();
$width = w2PgetParam($_GET, 'width', 600);
$start_date = w2PgetParam($_GET, 'start_date', 0);
$end_date = w2PgetParam($_GET, 'end_date', 0);
$showAllGantt = w2PgetParam($_REQUEST, 'showAllGantt', '1');
$gantt = new w2p_Output_GanttRenderer($AppUI, $width);
$gantt->localize();
$original_project = new CProject();
$original_project->load($original_project_id);
$tableTitle = $original_project->project_name . ': ' . $AppUI->_('Multi-Project Gantt');
$gantt->setTitle($tableTitle, '#eeeeee');
$columnNames = array('Project name', 'Start Date', 'Finish', 'Actual End');
示例9: db_error
$q = new DBQuery();
$q->addTable('forums');
$q->addWhere("forums.forum_id = {$forum_id}");
$res = $q->exec();
echo db_error();
$forum_info = db_fetch_assoc($res);
$status = isset($forum_info["forum_status"]) ? $forum_info["forum_status"] : -1;
// get any project records denied from viewing
$projObj = new CProject();
//Pull project Information
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('project_id, project_name');
$q->addWhere('project_status <> 7');
$q->addOrder('project_name');
$projObj->setAllowedSQL($AppUI->user_id, $q);
if (isset($company_id)) {
$q->addWhere("project_company = {$company_id}");
}
$projects = array('0' => '') + $q->loadHashList();
echo db_error();
if (!in_array($forum_project, array_keys($projects))) {
$forum_project = 0;
}
$perms =& $AppUI->acl();
$permittedUsers =& $perms->getPermittedUsers();
$users = array('0' => '') + $permittedUsers;
// setup the title block
$ttl = $forum_id > 0 ? "Edit Forum" : "Add Forum";
$titleBlock = new CTitleBlock($ttl, 'support.png', $m, "{$m}.{$a}");
$titleBlock->addCrumb("?m=forums", "forums list");
示例10: projectSelectWithOptGroup
/**
** Provide Projects Selectbox sorted by Companies
** @author gregorerhardt with special thanks to original author aramis
** @param int userID
** @param string HTML select box name identifier
** @param string HTML attributes
** @param int Proejct ID for preselection
** @param int Project ID which will be excluded from the list
** (e.g. in the tasks import list exclude the project to import into)
** @return string HTML selectbox
*/
function projectSelectWithOptGroup($user_id, $select_name, $select_attribs, $selected, $excludeProjWithId = null)
{
global $AppUI;
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('project_id, co.company_name, project_name');
if (!empty($excludeProjWithId)) {
$q->addWhere('project_id != ' . $excludeProjWithId);
}
$proj = new CProject();
$proj->setAllowedSQL($user_id, $q);
$q->addOrder('co.company_name, project_name');
$projects = $q->loadList();
$s = "\n" . '<select name="' . $select_name . '"' . ($select_attribs ? ' ' . $select_attribs : '') . '>';
$s .= "\n\t" . '<option value="0"' . ($selected == 0 ? ' selected="selected"' : '') . ' >' . $AppUI->_('None') . '</option>';
$current_company = '';
foreach ($projects as $p) {
if ($p['company_name'] != $current_company) {
$current_company = $AppUI->___($p['company_name']);
$s .= "\n" . '<optgroup label="' . $current_company . '" >' . $current_company . '</optgroup>';
}
$s .= "\n\t" . '<option value="' . $p['project_id'] . '"' . ($selected == $p['project_id'] ? ' selected="selected"' : '') . '> ' . $AppUI->___($p['project_name']) . '</option>';
}
$s .= "\n</select>\n";
return $s;
}
示例11: projectSelectWithOptGroup
/**
** Provide Projects Selectbox sorted by Companies
** @author gregorerhardt with special thanks to original author aramis
** @param int userID
** @param string HTML select box name identifier
** @param string HTML attributes
** @param int Proejct ID for preselection
** @param int Project ID which will be excluded from the list
** (e.g. in the tasks import list exclude the project to import into)
** @return string HTML selectbox
*/
function projectSelectWithOptGroup($user_id, $select_name, $select_attribs, $selected, $excludeProjWithId = null)
{
global $AppUI;
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('project_id, co.company_name, project_name');
if (!empty($excludeProjWithId)) {
$q->addWhere('project_id != ' . $excludeProjWithId);
}
$proj = new CProject();
$proj->setAllowedSQL($user_id, $q);
$q->addOrder('co.company_name, project_name');
$projects = $q->loadList();
$s = "\n<select name=\"{$select_name}\" {$select_attribs}>";
$s .= "\n\t<option value=\"0\" " . ($selected == 0 ? "selected=\"selected\"" : "") . " >" . $AppUI->_('None') . "</option>";
$current_company = "";
foreach ($projects as $p) {
if ($p['company_name'] != $current_company) {
$current_company = $p['company_name'];
$s .= "\n<optgroup label=\"" . $current_company . "\" >" . $current_company . "</optgroup>";
}
$s .= "\n\t<option value=\"" . $p['project_id'] . "\"" . ($selected == $p['project_id'] ? " selected=\"selected\"" : '') . "> " . $p['project_name'] . "</option>";
}
$s .= "\n</select>\n";
return $s;
}
示例12: CProject
$q->addTable('tasks', 'a');
$q->addTable('projects', 'pr');
$q->addWhere('a.task_project = pr.project_id');
$q->addJoin('users', 'b', 'a.task_owner = b.user_id', 'inner');
$q->addJoin('contacts', 'ct', 'ct.contact_id = b.user_contact', 'inner');
$q->addWhere('task_percent_complete = 100');
$q->addWhere('pr.project_active = 1');
if (($template_status = w2PgetConfig('template_projects_status_id')) != '') {
$q->addWhere('pr.project_status <> ' . $template_status);
}
if ($project_id != 0) {
$q->addWhere('task_project = ' . (int) $project_id);
}
$q->addWhere('task_end_date BETWEEN \'' . $last_week->format(FMT_DATETIME_MYSQL) . '\' AND \'' . $date->format(FMT_DATETIME_MYSQL) . '\'');
$proj = new CProject();
$q = $proj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
$obj = new CTask();
$q = $obj->setAllowedSQL($AppUI->user_id, $q);
$tasks = $q->loadHashList('task_id');
if ($err = db_error()) {
$AppUI->setMsg($err, UI_MSG_ERROR);
$AppUI->redirect('m=' . $m);
}
// Now grab the resources allocated to the tasks.
$task_list = array_keys($tasks);
$assigned_users = array();
// Build the array
foreach ($task_list as $tid) {
$assigned_users[$tid] = array();
}
if (count($tasks)) {
示例13: projectSelectWithOptGroup
/**
** Provide Projects Selectbox sorted by Companies
** @author gregorerhardt with special thanks to original author aramis
** @param int userID
** @param string HTML select box name identifier
** @param string HTML attributes
** @param int Proejct ID for preselection
** @param int Project ID which will be excluded from the list
** (e.g. in the tasks import list exclude the project to import into)
** @return string HTML selectbox
*/
function projectSelectWithOptGroup($user_id, $select_name, $select_attribs, $selected, $excludeProjWithId = null)
{
global $AppUI;
$q = new w2p_Database_Query();
$q->addTable('projects', 'pr');
$q->addQuery('DISTINCT pr.project_id, co.company_name, project_name');
$q->addJoin('companies', 'co', 'co.company_id = pr.project_company');
if (!empty($excludeProjWithId)) {
$q->addWhere('pr.project_id <> ' . $excludeProjWithId);
}
$proj = new CProject();
$q = $proj->setAllowedSQL($user_id, $q, null, 'pr');
$q->addOrder('co.company_name, project_name');
$projects = $q->loadList();
$s = '<select name="' . $select_name . '" ' . $select_attribs . '>';
$s .= '<option value="0" ' . ($selected == 0 ? 'selected="selected"' : '') . ' >' . $AppUI->_('None') . '</option>';
$current_company = '';
foreach ($projects as $p) {
if ($p['company_name'] != $current_company) {
$current_company = $p['company_name'];
$s .= '<optgroup label="' . $current_company . '" >' . $current_company . '</optgroup>';
}
$s .= '<option value="' . $p['project_id'] . '" ' . ($selected == $p['project_id'] ? 'selected="selected"' : '') . '> ' . $p['project_name'] . '</option>';
}
$s .= '</select>';
return $s;
}
示例14: projects_list_data
//.........这里部分代码省略.........
$owner_ids = $q->loadColumn();
$q->clear();
}
if (isset($department)) {
//If a department is specified, we want to display projects from the department, and all departments under that, so we need to build that list of departments
$dept_ids = array();
$q->addTable('departments');
$q->addQuery('dept_id, dept_parent');
$q->addOrder('dept_parent,dept_name');
$rows = $q->loadList();
addDeptId($rows, $department);
$dept_ids[] = isset($department->dept_id) ? $department->dept_id : 0;
$dept_ids[] = $department > 0 ? $department : 0;
}
$q->clear();
// retrieve list of records
// modified for speed
// by Pablo Roca (pabloroca@mvps.org)
// 16 August 2003
// get the list of permitted companies
$obj = new CCompany();
$companies = $obj->getAllowedRecords($AppUI->user_id, 'companies.company_id,companies.company_name', 'companies.company_name');
if (count($companies) == 0) {
$companies = array();
}
$q->addTable('projects', 'pr');
$q->addQuery('pr.project_id, project_status, project_color_identifier, project_type, project_name, project_description, project_duration, project_parent, project_original_parent,
project_start_date, project_end_date, project_color_identifier, project_company, company_name, company_description, project_status,
project_priority, tc.critical_task, tc.project_actual_end_date, tp.task_log_problem, pr.project_task_count, tsy.my_tasks,
pr.project_percent_complete, user_username, project_active');
$q->addQuery('CONCAT(ct.contact_first_name, \' \', ct.contact_last_name) AS owner_name');
$q->addJoin('users', 'u', 'pr.project_owner = u.user_id');
$q->addJoin('contacts', 'ct', 'ct.contact_id = u.user_contact');
$q->addJoin('tasks_critical', 'tc', 'pr.project_id = tc.task_project');
$q->addJoin('tasks_problems', 'tp', 'pr.project_id = tp.task_project');
$q->addJoin('tasks_sum', 'ts', 'pr.project_id = ts.task_project');
$q->addJoin('tasks_summy', 'tsy', 'pr.project_id = tsy.task_project');
if ($addProjectsWithAssignedTasks) {
$q->addJoin('tasks_users', 'tu', 'pr.project_id = tu.task_project');
}
if (!isset($department) && $company_id && !$addPwOiD) {
$q->addWhere('pr.project_company = ' . (int) $company_id);
}
if ($project_type > -1) {
$q->addWhere('pr.project_type = ' . (int) $project_type);
}
if (isset($department) && !$addPwOiD) {
$q->addWhere('project_departments.department_id in ( ' . implode(',', $dept_ids) . ' )');
}
if ($user_id && $addProjectsWithAssignedTasks) {
$q->addWhere('(tu.user_id = ' . (int) $user_id . ' OR pr.project_owner = ' . (int) $user_id . ' )');
} elseif ($user_id) {
$q->addWhere('pr.project_owner = ' . (int) $user_id);
}
if ($owner > 0) {
$q->addWhere('pr.project_owner = ' . (int) $owner);
}
if (mb_trim($search_text)) {
$q->addWhere('pr.project_name LIKE \'%' . $search_text . '%\' OR pr.project_description LIKE \'%' . $search_text . '%\'');
}
// Show Projects where the Project Owner is in the given department
if ($addPwOiD && !empty($owner_ids)) {
$q->addWhere('pr.project_owner IN (' . implode(',', $owner_ids) . ')');
}
$q->addGroup('pr.project_id');
$q->addOrder($orderby . ' ' . $orderdir);
$prj = new CProject();
$prj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
$dpt = new CDepartment();
$projects = $q->loadList();
// get the list of permitted companies
$companies = arrayMerge(array('0' => $AppUI->_('All')), $companies);
$company_array = $companies;
//get list of all departments, filtered by the list of permitted companies.
$q->clear();
$q->addTable('companies');
$q->addQuery('company_id, company_name, dep.*');
$q->addJoin('departments', 'dep', 'companies.company_id = dep.dept_company');
$q->addOrder('company_name,dept_parent,dept_name');
$obj->setAllowedSQL($AppUI->user_id, $q);
$dpt->setAllowedSQL($AppUI->user_id, $q);
$rows = $q->loadList();
//display the select list
$buffer = '<select name="department" id="department" onChange="document.pickCompany.submit()" class="text" style="width: 200px;">';
$company = '';
foreach ($company_array as $key => $c_name) {
$buffer .= '<option value="' . $company_prefix . $key . '" style="font-weight:bold;"' . ($company_id == $key ? 'selected="selected"' : '') . '>' . $c_name . '</option>' . "\n";
foreach ($rows as $row) {
if ($row['dept_parent'] == 0) {
if ($key == $row['company_id']) {
if ($row['dept_parent'] != null) {
showchilddept($row);
findchilddept($rows, $row['dept_id']);
}
}
}
}
}
$buffer .= '</select>';
}
示例15: CProject
$df = $AppUI->getPref('SHDATEFORMAT');
require_once $AppUI->getModuleClass('projects');
$project = new CProject();
if ($project_id > 0) {
$criticalTasks = $project->getCriticalTasks($project_id);
$project->load($project_id);
}
// pull valid projects and their percent complete information
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('project_id, project_color_identifier, project_name' . ', project_start_date, project_end_date');
$q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
$q->addWhere('project_status != 7');
$q->addGroup('project_id');
$q->addOrder('project_name');
$project->setAllowedSQL($AppUI->user_id, $q);
$projects = $q->loadHashList('project_id');
$q->clear();
$caller = defVal(@$_REQUEST['caller'], null);
/**
* if task filtering has been requested create the list of task_ids
* which will be used to filter the query
*/
if ($ganttTaskFilter > 0) {
$task_child_search = new CTask();
$task_child_search->peek($ganttTaskFilter);
//$childrenlist[] = $ganttTaskFilter;
//print_r($childrenlist);
$childrenlist = $task_child_search->getDeepChildren();
//print_r($childrenlist);
$where .= ' t.task_id IN (' . $ganttTaskFilter . ', ' . implode(', ', $childrenlist) . ')';