本文整理汇总了PHP中ProjectMilestones::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectMilestones::instance方法的具体用法?PHP ProjectMilestones::instance怎么用?PHP ProjectMilestones::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectMilestones
的用法示例。
在下文中一共展示了ProjectMilestones::instance方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActiveMilestonesByUser
/**
* Returns milestones from active context and parent members of the active context
*
* @param User $user
* @return array
*/
static function getActiveMilestonesByUser(Contact $user, $context = null) {
if (is_null($context)) {
$context = active_context();
}
$members = array();
$parents = array();
foreach ($context as $k => $member) {
if ($member instanceof Member) {
if ($member->getDimension()->getCode() == 'tags') continue;
$members[] = $member->getId();
$tmp = $member->getParentMember();
while ($tmp != null){
$parents[] = $tmp->getId();
$tmp = $tmp->getParentMember();
}
}
}
$result = ProjectMilestones::instance()->listing(array(
"ignore_context" => true,
"member_ids" => $members,
"extra_member_ids" => $parents
));
$milestones = $result->objects;
return $milestones;
} // getActiveMilestonesByUser
示例2: getActiveMilestonesByUser
/**
* Returns milestones from active context and parent members of the active context
*
* @param User $user
* @return array
*/
static function getActiveMilestonesByUser(Contact $user, $context = null)
{
if (is_null($context)) {
$context = active_context();
}
$parents = array();
foreach ($context as $k => $member) {
if ($member instanceof Member) {
$tmp = $member->getParentMember();
while ($tmp != null) {
$parents[] = $tmp->getId();
$tmp = $tmp->getParentMember();
}
}
}
$extra_conditions = "";
/*
if (count($parents) > 0) {
$extra_conditions = "OR EXISTS (SELECT `aux`.`object_id` FROM ".ObjectMembers::instance()->getTableName(true)." `aux` WHERE `aux`.`is_optimization` = 0
AND `aux`.`object_id`=`om`.`object_id` AND `aux`.`member_id` IN (".implode(",",$parents)."))";
}
$result = ProjectMilestones::getContentObjects($context, ObjectTypes::findById(ProjectMilestones::instance()->getObjectTypeId()), null, null, $extra_conditions);
*/
$result = ProjectMilestones::instance()->listing(array("extra_conditions" => $extra_conditions, "extra_member_ids" => $parents));
$milestones = $result->objects;
return $milestones;
}
示例3: getProjectsByUser
/**
* Return all projects that this user is part of
*
* @access public
* @param User $user
* @param
* @return array
*/
function getProjectsByUser(User $user, $additional_conditions = null, $additional_sort = null)
{
trace(__FILE__, "getProjectsByUser(user, {$additional_conditions}, {$additional_sort})");
$projects_table = Projects::instance()->getTableName(true);
trace(__FILE__, "getProjectsByUser():1");
$project_users_table = ProjectUsers::instance()->getTableName(true);
trace(__FILE__, "getProjectsByUser():2");
$project_milestones_table = ProjectMilestones::instance()->getTableName(true);
trace(__FILE__, "getProjectsByUser():3");
$empty_datetime = DB::escape(EMPTY_DATETIME);
$projects = array();
if (trim($additional_sort) == 'milestone') {
$sql = "SELECT distinct {$projects_table}.* FROM {$projects_table}";
$sql .= " left outer join {$project_milestones_table} on {$project_milestones_table}.`project_id` = {$projects_table}.`id`";
$sql .= " inner join {$project_users_table} on {$projects_table}.`id` = {$project_users_table}.`project_id`";
$sql .= " where {$project_users_table}.`user_id` = " . DB::escape($user->getId()) . " and ({$project_milestones_table}.`completed_on` = {$empty_datetime} or isnull({$project_milestones_table}.`completed_on`))";
} else {
$sql = "SELECT {$projects_table}.* FROM {$projects_table}, {$project_users_table} WHERE ({$projects_table}.`id` = {$project_users_table}.`project_id` AND {$project_users_table}.`user_id` = " . DB::escape($user->getId()) . ')';
}
if (trim($additional_conditions) != '') {
$sql .= " AND ({$additional_conditions})";
}
// if
if (trim($additional_sort) == 'priority') {
$sql .= " ORDER BY isnull({$projects_table}.`priority`), {$projects_table}.`priority`, {$projects_table}.`name`";
} elseif (trim($additional_sort) == 'milestone') {
$sql .= " ORDER BY isnull({$project_milestones_table}.`due_date`), {$project_milestones_table}.`due_date`, {$projects_table}.`name` ";
} else {
$sql .= " ORDER BY {$projects_table}.`name`";
}
trace(__FILE__, "getProjectsByUser(): sql={$sql}");
$rows = DB::executeAll($sql);
trace(__FILE__, "getProjectsByUser(): sql={$sql} ok");
if (is_array($rows)) {
foreach ($rows as $row) {
$projects[] = Projects::instance()->loadFromRow($row);
}
// foreach
}
// if
return count($projects) ? $projects : null;
}
示例4: manager
/**
* Return manager instance
*
* @access protected
* @param void
* @return ProjectMilestones
*/
function manager() {
if(!($this->manager instanceof ProjectMilestones)) $this->manager = ProjectMilestones::instance();
return $this->manager;
} // manager
示例5: new_list_tasks
//.........这里部分代码省略.........
$task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` = '{$now}'";
break;
case 13:
// Today + Overdue tasks
$task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
break;
case 14:
// Today + Overdue tasks
$task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
break;
case 20:
// Actives task by current user
$task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}' AND `assigned_to_contact_id` = " . logged_user()->getId();
break;
case 21:
// Subscribed tasks by current user
$res20 = DB::execute("SELECT object_id FROM " . TABLE_PREFIX . "object_subscriptions WHERE `contact_id` = " . logged_user()->getId());
$subs_rows = $res20->fetchAll($res20);
foreach ($subs_rows as $row) {
$subs[] = $row['object_id'];
}
unset($res20, $subs_rows, $row);
$task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `id` IN(" . implode(',', $subs) . ")";
break;
case 2:
// All tasks
break;
default:
throw new Exception('Task status "' . $status . '" not recognised');
}
$conditions = "AND {$template_condition} {$task_filter_condition} {$task_status_condition}";
//Now get the tasks
//$tasks = ProjectTasks::getContentObjects(active_context(), ObjectTypes::findById(ProjectTasks::instance()->getObjectTypeId()), null, null, $conditions,null)->objects;
$tasks = ProjectTasks::instance()->listing(array("extra_conditions" => $conditions, "start" => 0, "limit" => 501, "count_results" => false))->objects;
$pendingstr = $status == 0 ? " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " " : "";
$milestone_conditions = " AND `is_template` = false " . $pendingstr;
//Find all internal milestones for these tasks
//$internalMilestones = ProjectMilestones::getContentObjects(active_context(), ObjectTypes::findById(ProjectMilestones::instance()->getObjectTypeId()), null, null, $milestone_conditions,null)->objects;
$internalMilestones = ProjectMilestones::instance()->listing(array("extra_conditions" => $milestone_conditions))->objects;
//Find all external milestones for these tasks, external milestones are the ones that belong to a parent member and have tasks in the current member
$milestone_ids = array();
if ($tasks) {
foreach ($tasks as $task) {
if ($task->getMilestoneId() != 0) {
$milestone_ids[$task->getMilestoneId()] = $task->getMilestoneId();
}
}
}
$int_milestone_ids = array();
foreach ($internalMilestones as $milestone) {
$int_milestone_ids[] = $milestone->getId();
}
$milestone_ids = array_diff($milestone_ids, $int_milestone_ids);
if (count($milestone_ids) == 0) {
$milestone_ids[] = 0;
}
$ext_milestone_conditions = " `is_template` = false " . $pendingstr . ' AND `object_id` IN (' . implode(',', $milestone_ids) . ')';
$externalMilestones = ProjectMilestones::findAll(array('conditions' => $ext_milestone_conditions));
// Get Users Info
$users = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), active_context(), ACCESS_LEVEL_READ);
$allUsers = Contacts::getAllUsers();
$user_ids = array(-1);
foreach ($users as $user) {
$user_ids[] = $user->getId();
}
// only companies with users
示例6: getOverdueAndUpcomingObjects
static function getOverdueAndUpcomingObjects($limit = null) {
$conditions_tasks = " AND is_template = 0 AND `e`.`completed_by_id` = 0 AND `e`.`due_date` > 0";
$conditions_milestones = " AND is_template = 0 AND `e`.`completed_by_id` = 0 AND `e`.`due_date` > 0";
if (!SystemPermissions::userHasSystemPermission(logged_user(), 'can_see_assigned_to_other_tasks')) {
$conditions_tasks .= " AND assigned_to_contact_id = ".logged_user()->getId();
}
$tasks_result = self::instance()->listing(array(
"limit" => $limit,
"extra_conditions" => $conditions_tasks,
"order"=> array('due_date', 'priority'),
"order_dir" => "ASC"
));
$tasks = $tasks_result->objects;
$milestones_result = ProjectMilestones::instance()->listing(array(
"limit" => $limit,
"extra_conditions" => $conditions_milestones,
"order" => array('due_date'),
"order_dir" => "ASC"
));
$milestones = $milestones_result->objects;
$ordered = array();
foreach ($tasks as $task) { /* @var $task ProjectTask */
if (!$task->isCompleted() && $task->getDueDate() instanceof DateTimeValue ) {
if (!isset($ordered[$task->getDueDate()->getTimestamp()])){
$ordered[$task->getDueDate()->getTimestamp()] = array();
}
$ordered[$task->getDueDate()->getTimestamp()][] = $task;
}
}
foreach ($milestones as $milestone) {
if (!isset($ordered[$milestone->getDueDate()->getTimestamp()])) {
$ordered[$milestone->getDueDate()->getTimestamp()] = array();
}
$ordered[$milestone->getDueDate()->getTimestamp()][] = $milestone;
}
ksort($ordered, SORT_NUMERIC);
$ordered_flat = array();
foreach ($ordered as $k => $values) {
foreach ($values as $v) $ordered_flat[] = $v;
}
return $ordered_flat;
}
示例7: paginate
/**
* This function will return paginated result. Result is an array where first element is
* array of returned object and second populated pagination object that can be used for
* obtaining and rendering pagination data using various helpers.
*
* Items and pagination array vars are indexed with 0 for items and 1 for pagination
* because you can't use associative indexing with list() construct
*
* @access public
* @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
* @param integer $items_per_page Number of items per page
* @param integer $current_page Current page number
* @return array
*/
function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
{
if (isset($this) && instance_of($this, 'ProjectMilestones')) {
return parent::paginate($arguments, $items_per_page, $current_page);
} else {
return ProjectMilestones::instance()->paginate($arguments, $items_per_page, $current_page);
//$instance =& ProjectMilestones::instance();
//return $instance->paginate($arguments, $items_per_page, $current_page);
}
// if
}
示例8: manager
/**
* Return manager instance
*
* @access protected
* @param void
* @return ProjectMilestones
*/
function manager()
{
if (!$this->manager instanceof ProjectMilestones) {
$this->manager = ProjectMilestones::instance();
}
return $this->manager;
}
示例9: new_list_tasks
function new_list_tasks()
{
//load config options into cache for better performance
load_user_config_options_by_category_name('task panel');
$isJson = array_var($_GET, 'isJson', false);
if ($isJson) {
ajx_current("empty");
}
$request_conditions = $this->get_tasks_request_conditions();
$conditions = $request_conditions['conditions'];
$filter_value = $request_conditions['filterValue'];
$filter = $request_conditions['filter'];
$status = $request_conditions['status'];
$tasks = array();
$pendingstr = $status == 0 ? " AND `e`.`completed_on` = " . DB::escape(EMPTY_DATETIME) . " " : "";
$milestone_conditions = " AND `is_template` = false " . $pendingstr;
//Find all internal milestones for these tasks
$internalMilestones = ProjectMilestones::instance()->listing(array("extra_conditions" => $milestone_conditions))->objects;
//Find all external milestones for these tasks, external milestones are the ones that belong to a parent member and have tasks in the current member
$milestone_ids = array();
$task_ids = array();
if ($tasks) {
foreach ($tasks as $task) {
$task_ids[] = $task['id'];
if ($task['milestone_id'] != 0) {
$milestone_ids[$task['milestone_id']] = $task['milestone_id'];
}
}
// generate request cache
ObjectMembers::instance()->getCachedObjectMembers(0, $task_ids);
ProjectTasks::instance()->findByRelatedCached(0, $task_ids);
}
$cp_values = array();
if (count($task_ids) > 0) {
$cp_rows = DB::executeAll("SELECT * FROM " . TABLE_PREFIX . "custom_property_values WHERE object_id IN (" . implode(',', $task_ids) . ")");
if (is_array($cp_rows)) {
foreach ($cp_rows as $row) {
if (!isset($cp_values[$row['object_id']])) {
$cp_values[$row['object_id']] = array();
}
if (!isset($cp_values[$row['object_id']][$row['custom_property_id']])) {
$cp_values[$row['object_id']][$row['custom_property_id']] = array();
}
$cp_values[$row['object_id']][$row['custom_property_id']][] = $row['value'];
}
}
}
tpl_assign('cp_values', $cp_values);
$int_milestone_ids = array();
foreach ($internalMilestones as $milestone) {
$int_milestone_ids[] = $milestone->getId();
}
$milestone_ids = array_diff($milestone_ids, $int_milestone_ids);
if (count($milestone_ids) == 0) {
$milestone_ids[] = 0;
}
$ext_milestone_conditions = " `is_template` = false " . $pendingstr . ' AND `object_id` IN (' . implode(',', $milestone_ids) . ')';
$externalMilestones = ProjectMilestones::findAll(array('conditions' => $ext_milestone_conditions));
// Get Users Info
if (logged_user()->isGuest()) {
$users = array(logged_user());
} else {
$users = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), active_context(), ACCESS_LEVEL_READ, '', true);
}
$allUsers = Contacts::getAllUsers(null, true);
$user_ids = array(-1);
foreach ($allUsers as $user) {
$user_ids[] = $user->getId();
}
// only companies with users
$companies = Contacts::findAll(array("conditions" => "e.is_company = 1", "join" => array("table" => Contacts::instance()->getTableName(), "jt_field" => "object_id", "j_sub_q" => "SELECT xx.object_id FROM " . Contacts::instance()->getTableName(true) . " xx WHERE \r\n\t\t\t\t\txx.is_company=0 AND xx.company_id = e.object_id AND xx.object_id IN (" . implode(",", $user_ids) . ") LIMIT 1")));
tpl_assign('tasks', $tasks);
if (!$isJson) {
$all_templates = COTemplates::findAll(array('conditions' => '`trashed_by_id` = 0 AND `archived_by_id` = 0'));
tpl_assign('all_templates', $all_templates);
if (user_config_option('task_display_limit') > 0 && count($tasks) > user_config_option('task_display_limit')) {
tpl_assign('displayTooManyTasks', true);
array_pop($tasks);
}
tpl_assign('object_subtypes', array());
tpl_assign('internalMilestones', $internalMilestones);
tpl_assign('externalMilestones', $externalMilestones);
tpl_assign('users', $users);
tpl_assign('allUsers', $allUsers);
tpl_assign('companies', $companies);
if (strtotime(user_config_option('tasksDateStart'))) {
//this return null if date is 0000-00-00 00:00:00
$dateStart = new DateTime('@' . strtotime(user_config_option('tasksDateStart')));
$dateStart = $dateStart->format(user_config_option('date_format'));
} else {
$dateStart = '';
}
if (strtotime(user_config_option('tasksDateEnd'))) {
//this return null if date is 0000-00-00 00:00:00
$dateEnd = new DateTime('@' . strtotime(user_config_option('tasksDateEnd')));
$dateEnd = $dateEnd->format(user_config_option('date_format'));
} else {
$dateEnd = '';
}
$userPref = array();
//.........这里部分代码省略.........
示例10: canAdd
function canAdd(Contact $user, $context, &$notAllowedMember = '')
{
return can_add($user, $context, ProjectMilestones::instance()->getObjectTypeId(), $notAllowedMember);
}
示例11: getDashboardObjectQueries
/**
* Returns array of queries that will return Dashboard Objects
*
* @param string $proj_ids
* @param string $tag
* @param boolean $count if false the query will return objects, if true it will return object count
*/
static function getDashboardObjectQueries($project = null, $tag = null, $count = false, $trashed = false, $linkedObject = null, $order = 'updatedOn', $filterName = '', $archived = false, $filterManager = '')
{
if ($trashed && $trashed !== 'all') {
$order = 'trashedOn';
} else {
if ($archived) {
$order = 'archivedOn';
}
}
switch ($order) {
case 'dateCreated':
$order_crit_companies = '`created_on`';
$order_crit_contacts = '`created_on`';
$order_crit_file_revisions = '`created_on`';
$order_crit_calendar = '`created_on`';
$order_crit_tasks = '`created_on`';
$order_crit_milestones = '`created_on`';
$order_crit_webpages = '`created_on`';
$order_crit_files = '`created_on`';
$order_crit_emails = '`received_date`';
$order_crit_comments = '`created_on`';
$order_crit_messages = '`created_on`';
$order_crit_workspaces = '`created_on`';
break;
case 'trashedOn':
$order_crit_companies = '`trashed_on`';
$order_crit_contacts = '`trashed_on`';
$order_crit_file_revisions = '`trashed_on`';
$order_crit_calendar = '`trashed_on`';
$order_crit_tasks = '`trashed_on`';
$order_crit_milestones = '`trashed_on`';
$order_crit_webpages = '`trashed_on`';
$order_crit_files = '`trashed_on`';
$order_crit_emails = '`trashed_on`';
$order_crit_comments = '`trashed_on`';
$order_crit_messages = '`trashed_on`';
$order_crit_workspaces = '`updated_on`';
break;
case 'archivedOn':
$order_crit_companies = '`archived_on`';
$order_crit_contacts = '`archived_on`';
$order_crit_file_revisions = '`updated_on`';
$order_crit_calendar = '`archived_on`';
$order_crit_tasks = '`archived_on`';
$order_crit_milestones = '`archived_on`';
$order_crit_webpages = '`archived_on`';
$order_crit_files = '`archived_on`';
$order_crit_emails = '`archived_on`';
$order_crit_comments = '`updated_on`';
$order_crit_messages = '`archived_on`';
$order_crit_workspaces = '`completed_on`';
break;
case 'name':
$order_crit_companies = '`name`';
$order_crit_contacts = "TRIM(CONCAT(' ', `lastname`, `firstname`, `middlename`))";
$order_crit_file_revisions = "'zzzzzzzzzzzzzz'";
//Revisar
$order_crit_calendar = '`subject`';
$order_crit_tasks = '`title`';
$order_crit_milestones = '`name`';
$order_crit_webpages = '`title`';
$order_crit_files = '`filename`';
$order_crit_emails = '`subject`';
$order_crit_comments = '`text`';
$order_crit_messages = '`title`';
$order_crit_workspaces = '`name`';
break;
default:
$order_crit_companies = '`updated_on`';
$order_crit_contacts = '`updated_on`';
$order_crit_file_revisions = '`updated_on`';
$order_crit_calendar = '`updated_on`';
$order_crit_tasks = '`updated_on`';
$order_crit_milestones = '`updated_on`';
$order_crit_webpages = '`updated_on`';
$order_crit_files = '`updated_on`';
$order_crit_emails = '`received_date`';
$order_crit_comments = '`updated_on`';
$order_crit_messages = '`updated_on`';
$order_crit_workspaces = '`updated_on`';
break;
}
if ($project instanceof Project) {
$proj_ids = $project->getAllSubWorkspacesQuery(true);
$proj_cond_companies = Companies::getWorkspaceString($proj_ids);
$proj_cond_messages = ProjectMessages::getWorkspaceString($proj_ids);
$proj_cond_documents = ProjectFiles::getWorkspaceString($proj_ids);
$proj_cond_emails = MailContents::getWorkspaceString($proj_ids);
$proj_cond_events = ProjectEvents::getWorkspaceString($proj_ids);
$proj_cond_tasks = ProjectTasks::getWorkspaceString($proj_ids);
$proj_cond_charts = ProjectCharts::getWorkspaceString($proj_ids);
$proj_cond_milestones = ProjectMilestones::getWorkspaceString($proj_ids);
$proj_cond_weblinks = ProjectWebpages::getWorkspaceString($proj_ids);
//.........这里部分代码省略.........
示例12: canAdd
/**
* Check if specific user can add new milestones to specific project
*
* @access public
* @param User $user
* @param Project $project
* @return boolean
*/
function canAdd(User $user, Project $project)
{
return can_add($user, $project, get_class(ProjectMilestones::instance()));
}
示例13: can_add_to_member
/**
* Return true if $user can add an object of type $object_type_id in $member. False otherwise.
*
* @param Contact $user
* @param Member $member
* @param array $context_members
* @param $object_type_id
* @return boolean
*/
function can_add_to_member(Contact $user, $member, $context_members, $object_type_id, $check_dimension = true)
{
if (TemplateTasks::instance()->getObjectTypeId() == $object_type_id) {
$object_type_id = ProjectTasks::instance()->getObjectTypeId();
}
if (TemplateMilestones::instance()->getObjectTypeId() == $object_type_id) {
$object_type_id = ProjectMilestones::instance()->getObjectTypeId();
}
if (!$member instanceof Member && is_array($member) && isset($member['id'])) {
$member = Members::findById($member['id']);
}
if ($user->isGuest() || !$member || !$member->canContainObject($object_type_id)) {
return false;
}
try {
$contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV($user->getId(), false);
if ($check_dimension) {
$dimension = $member->getDimension();
}
//dimension does not define permissions - user can freely add in all members
if ($check_dimension && !$dimension->getDefinesPermissions()) {
return true;
}
//dimension defines permissions and user has maximum level of permissions so can freely in all members
if ($check_dimension && $dimension->hasAllowAllForContact($contact_pg_ids)) {
return true;
}
//check
if (ContactMemberPermissions::contactCanReadObjectTypeinMember($contact_pg_ids, $member->getId(), $object_type_id, true, false, $user)) {
$max_role_ot_perm = MaxRoleObjectTypePermissions::instance()->findOne(array('conditions' => "object_type_id='{$object_type_id}' AND role_id = '" . $user->getUserType() . "'"));
// if user max permission cannot write this object type then return false
if ($max_role_ot_perm && $max_role_ot_perm->getCanWrite()) {
return true;
} else {
return false;
}
}
//check for context permissions that allow user to add in this member
if ($context_members) {
$member_ids = array();
foreach ($context_members as $member_obj) {
$member_ids[] = $member_obj->getId();
}
$allowed_members = ContactMemberPermissions::getActiveContextPermissions($user, $object_type_id, $context_members, $member_ids, true);
if (in_array($member, $allowed_members)) {
return true;
}
}
} catch (Exception $e) {
tpl_assign('error', $e);
return false;
}
return false;
}
示例14: getProjectMilestones
static function getProjectMilestones($project = null, $order = null, $orderdir = 'DESC', $tag = null, $assigned_to_company = null, $assigned_to_user = null, $assigned_by_user = null, $pending = false, $is_template = false, $archived = false)
{
// default
$order_by = '`due_date` ASC';
if ($project instanceof Project) {
$pids = $project->getAllSubWorkspacesQuery(!$archived);
$projectstr = " AND " . self::getWorkspaceString($pids);
} else {
$projectstr = "";
}
if ($tag == '' || $tag == null) {
$tagstr = "";
} else {
$tagstr = " AND (select count(*) from " . TABLE_PREFIX . "tags where " . TABLE_PREFIX . "project_milestones.id = " . TABLE_PREFIX . "tags.rel_object_id and " . TABLE_PREFIX . "tags.tag = " . DB::escape($tag) . " and " . TABLE_PREFIX . "tags.rel_object_manager ='ProjectMilestones' ) > 0 ";
}
$assignedToStr = "";
if ($assigned_to_company) {
$assignedToStr .= " AND `assigned_to_company_id` = " . DB::escape($assigned_to_company) . " ";
}
if ($assigned_to_user) {
$assignedToStr .= " AND `assigned_to_user_id` = " . DB::escape($assigned_to_user) . " ";
}
$assignedByStr = "";
if ($assigned_by_user) {
$assignedByStr .= " AND (`created_by_id` = " . DB::escape($assigned_by_user) . " OR `updated_by_id` = " . DB::escape($assigned_by_user) . ") ";
}
if ($pending) {
$pendingstr = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " ";
} else {
$pendingstr = "";
}
if ($pending) {
$pendingstr = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " ";
} else {
$pendingstr = "";
}
if ($archived) {
$archived_cond = " AND `archived_by_id` <> 0";
} else {
$archived_cond = " AND `archived_by_id` = 0";
}
$permissionstr = ' AND ( ' . permissions_sql_for_listings(ProjectMilestones::instance(), ACCESS_LEVEL_READ, logged_user()) . ') ';
$otherConditions = $projectstr . $tagstr . $assignedToStr . $assignedByStr . $permissionstr . $pendingstr . $archived_cond;
$conditions = array(' `is_template` = ' . DB::escape($is_template) . $otherConditions);
$milestones = ProjectMilestones::find(array('conditions' => $conditions, 'order' => $order_by));
if (!is_array($milestones)) {
$milestones = array();
}
return $milestones;
}