/** * Construct discussions controller * * @param Request $request * @return DiscussionsController */ function __construct($request) { parent::__construct($request); if ($this->logged_user->getProjectPermission('discussion', $this->active_project) < PROJECT_PERMISSION_ACCESS) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $discussions_url = discussions_module_url($this->active_project); $this->wireframe->addBreadCrumb(lang('Discussions'), $discussions_url); $add_discussion_url = false; if (Discussion::canAdd($this->logged_user, $this->active_project)) { if ($this->active_category->isLoaded()) { $add_discussion_url = discussions_module_add_discussion_url($this->active_project, array('category_id' => $this->active_category->getId())); } else { $add_discussion_url = discussions_module_add_discussion_url($this->active_project); } // if $this->wireframe->addPageAction(lang('New Discussion'), $add_discussion_url); } // if $discussion_id = $this->request->getId('discussion_id'); if ($discussion_id) { $this->active_discussion = ProjectObjects::findById($discussion_id); } // if if (instance_of($this->active_discussion, 'Discussion')) { $this->wireframe->addBreadCrumb($this->active_discussion->getName(), $this->active_discussion->getViewUrl()); } else { $this->active_discussion = new Discussion(); } // if $this->smarty->assign(array('active_discussion' => $this->active_discussion, 'discussions_url' => $discussions_url, 'add_discussion_url' => $add_discussion_url, 'page_tab' => 'discussions')); }
/** * Constructor * * @param Request $request * @return ChecklistsController */ function __construct($request) { parent::__construct($request); if ($this->logged_user->getProjectPermission('checklist', $this->active_project) < PROJECT_PERMISSION_ACCESS) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $checklists_url = checklists_module_url($this->active_project); $checklists_archive_url = checklists_module_archive_url($this->active_project); $add_checklist_url = false; $this->wireframe->addBreadCrumb(lang('Checklists'), $checklists_url); if (Checklist::canAdd($this->logged_user, $this->active_project)) { $add_checklist_url = checklists_module_add_checklist_url($this->active_project); $this->wireframe->addPageAction(lang('New Checklist'), $add_checklist_url); } // if $checklist_id = $this->request->getId('checklist_id'); if ($checklist_id) { $this->active_checklist = ProjectObjects::findById($checklist_id); } // if if (instance_of($this->active_checklist, 'Checklist')) { if ($this->active_checklist->isCompleted()) { $this->wireframe->addBreadCrumb(lang('Archive'), checklists_module_archive_url($this->active_project)); } // if $this->wireframe->addBreadCrumb($this->active_checklist->getName(), $this->active_checklist->getViewUrl()); } else { $this->active_checklist = new Checklist(); } // if $this->smarty->assign(array('active_checklist' => $this->active_checklist, 'checklists_url' => $checklists_url, 'checklists_archive_url' => $checklists_archive_url, 'add_checklist_url' => $add_checklist_url, 'page_tab' => 'checklists')); }
/** * Constructor * * @param Request $request * @return FilesController */ function __construct($request) { parent::__construct($request); if ($this->logged_user->getProjectPermission('file', $this->active_project) < PROJECT_PERMISSION_ACCESS) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $files_url = files_module_url($this->active_project); $attachments_url = files_module_url($this->active_project, array('show_attachments' => true)); $this->wireframe->addBreadCrumb(lang('Files'), $files_url); $upload_url = false; if (File::canAdd($this->logged_user, $this->active_project)) { if ($this->active_category->isLoaded()) { $upload_url = files_module_upload_url($this->active_project, array('category_id' => $this->active_category->getId())); } else { $upload_url = files_module_upload_url($this->active_project); } // if $this->wireframe->addPageAction(lang('Upload Files'), $upload_url); } // if $file_id = $this->request->getId('file_id'); if ($file_id) { $this->active_file = ProjectObjects::findById($file_id); } // if if (instance_of($this->active_file, 'File')) { $this->wireframe->addBreadCrumb($this->active_file->getName(), $this->active_file->getViewUrl()); } else { $this->active_file = new File(); } // if $this->smarty->assign(array('active_file' => $this->active_file, 'files_url' => $files_url, 'attachments_url' => $attachments_url, 'upload_url' => $upload_url, 'page_tab' => 'files')); }
/** * Return related object * * @param void * @return ProjectObject */ function getObject() { if ($this->object === false) { $this->object = ProjectObjects::findById($this->getObjectId()); } // if return $this->object; }
/** * Return parent object * * @param void * @return ApplicationObject */ function &getParent() { if ($this->parent === false) { if (strtolower($this->getParentType()) == 'document') { $this->parent = $this->getParentId() ? Documents::findById($this->getParentId()) : null; } else { $this->parent = $this->getParentId() ? ProjectObjects::findById($this->getParentId()) : null; } // if } // if return $this->parent; }
/** * Constructor * * @param Request $request * @return ProjectObjectsController */ function __construct($request) { parent::__construct($request); $object_id = (int) $this->request->getId('object_id'); if ($object_id) { $this->active_object = ProjectObjects::findById($object_id); } // if if (instance_of($this->active_object, 'ProjectObject')) { $this->active_object->prepareProjectSectionBreadcrumb($this->wireframe); $this->wireframe->addBreadCrumb($this->active_object->getName(), $this->active_object->getViewUrl()); } else { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $this->smarty->assign(array('active_object' => $this->active_object, 'page_tab' => $this->active_object->getProjectTab())); }
/** * Constructor * * @param Request $request * @return MobileAccessController extends ApplicationController */ function __construct($request) { parent::__construct($request); $this->enableCategories(); if ($this->logged_user->getProjectPermission('page', $this->active_project) < PROJECT_PERMISSION_ACCESS) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $this->controller_description_name = lang('Pages'); $this->active_project_section = 'pages'; // Active page $this->active_page = ProjectObjects::findById($this->request->getId('object_id')); if (!instance_of($this->active_page, 'Page')) { $this->active_page = new Page(); } // if $this->addBreadcrumb($this->controller_description_name, assemble_url('mobile_access_view_pages', array('project_id' => $this->active_project->getId()))); $this->smarty->assign(array('active_page' => $this->active_page)); }
/** * Constructor * * @param Request $request * @return MilestonesController */ function __construct($request) { parent::__construct($request); if ($this->logged_user->getProjectPermission('milestone', $this->active_project) < PROJECT_PERMISSION_ACCESS) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $milestones_url = milestones_module_url($this->active_project); $add_milestone_url = milestones_module_add_url($this->active_project); $this->wireframe->addBreadCrumb(lang('Milestones'), $milestones_url); if (Milestone::canAdd($this->logged_user, $this->active_project)) { $this->wireframe->addPageAction(lang('New Milestone'), $add_milestone_url); } // if //$this->wireframe->addPageAction(lang('Today'), assemble_url('project_user_today_page', array('project_id' => $this->active_project->getId(), 'user_id' => $this->logged_user->getId()))); $milestone_id = $this->request->getId('milestone_id'); if ($milestone_id) { $this->active_milestone = ProjectObjects::findById($milestone_id); } // if //BOF: task 03 | AD $order_by_val = $_GET['order_by']; if (!empty($order_by_val)) { $this->order_by = $order_by_val; } $sort_order_val = $_GET['sort_order']; if (!empty($sort_order_val)) { $this->sort_order = $sort_order_val; } //EOF: task 03 | AD if (instance_of($this->active_milestone, 'Milestone')) { if ($this->active_milestone->getCompletedOn()) { $this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('project_milestones_archive', array('project_id' => $this->active_project->getId()))); } // if $this->wireframe->addBreadCrumb($this->active_milestone->getName(), $this->active_milestone->getViewUrl()); } else { $this->active_milestone = new Milestone(); } // if $this->smarty->assign(array('active_milestone' => $this->active_milestone, 'milestones_url' => $milestones_url, 'add_milestone_url' => $add_milestone_url, 'page_tab' => 'milestones', 'mass_edit_milestones_url' => assemble_url('project_milestones_mass_edit', array('project_id' => $this->active_project->getId())))); }
/** * Get view url for resulting object * * @return string */ function getResultingObjectUrl() { if ($this->getProjectObjectId()) { $object = ProjectObjects::findById($this->getProjectObjectId()); if (instance_of($object, 'ProjectObject')) { return $object->getViewUrl(); } // if } else { if ($this->getIncomingMailId()) { $object = IncomingMails::findById($this->getIncomingMailId()); if (instance_of($object, 'IncomingMail')) { return $object->getImportUrl(); } // if } } // if return false; }
/** * Constructor * * @param Request $request * @return MobileAccessController extends ApplicationController */ function __construct($request) { parent::__construct($request); if ($this->logged_user->getProjectPermission('milestone', $this->active_project) < PROJECT_PERMISSION_ACCESS) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $this->controller_description_name = lang('Milestones'); $this->active_project_section = 'milestones'; $milestone_id = $this->request->getId('object_id'); if ($milestone_id) { $this->active_milestone = ProjectObjects::findById($milestone_id); } // if if (!instance_of($this->active_milestone, 'Milestone')) { $this->active_milestone = new Milestone(); } // if $this->smarty->assign(array("active_milestone" => $this->active_milestone, "active_project_section" => $this->active_project_section)); $this->addBreadcrumb($this->controller_description_name, assemble_url('mobile_access_view_milestones', array('project_id' => $this->active_project->getId()))); }
/** * Constructor * * @param Request $request * @return TasksController */ function __construct($request) { parent::__construct($request); $task_id = $this->request->getId('task_id'); if ($task_id) { $this->active_task = Tasks::findById($task_id); } // if if (instance_of($this->active_task, 'Task')) { $this->active_task_parent = $this->active_task->getParent(); if (instance_of($this->active_task_parent, 'ProjectObject')) { $this->active_task_parent->prepareProjectSectionBreadcrumb($this->wireframe); } // if } else { $this->active_task = new Task(); $parent_id = $this->request->getId('parent_id'); if ($parent_id) { $parent = ProjectObjects::findById($parent_id); if (instance_of($parent, 'ProjectObject')) { $this->active_task_parent = $parent; $this->active_task_parent->prepareProjectSectionBreadcrumb($this->wireframe); } // if } // if } // if if (instance_of($this->active_task_parent, 'ProjectObject')) { $this->wireframe->addBreadCrumb($this->active_task_parent->getName(), $this->active_task_parent->getViewUrl()); } else { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $this->smarty->assign(array('active_task' => $this->active_task, 'active_task_parent' => $this->active_task_parent, 'page_tab' => $this->active_task->getProjectTab())); }
/** * Construct timetracking controller * * @param Request $request * @return TimetrackingController */ function __construct($request) { parent::__construct($request); if ($this->logged_user->getProjectPermission('timerecord', $this->active_project) < PROJECT_PERMISSION_ACCESS) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $time_url = timetracking_module_url($this->active_project); $time_add_url = timetracking_module_add_record_url($this->active_project); $this->wireframe->addBreadCrumb(lang('Time'), $time_url); if ($this->logged_user->isAdministrator() || $this->logged_user->getSystemPermission('use_time_reports')) { $this->wireframe->addPageAction(lang('Reports'), timetracking_module_reports_url($this->active_project), null, array('id' => 'timetracking_reports')); } // if $time_id = $this->request->getId('time_id'); if ($time_id) { $this->active_time = TimeRecords::findById($time_id); } // if if (!instance_of($this->active_time, 'TimeRecord')) { $this->active_time = new TimeRecord(); } // if $object_id = $this->request->getId('for'); if ($object_id) { $this->active_object = ProjectObjects::findById($object_id); } // if if (instance_of($this->active_object, 'ProjectObject')) { $time_url = timetracking_module_url($this->active_project, $this->active_object); $time_add_url = timetracking_module_add_record_url($this->active_project, array('for' => $this->active_object->getId())); $this->wireframe->addBreadCrumb($this->active_object->getName(), $time_url); } // if $this->smarty->assign(array('active_time' => $this->active_time, 'active_object' => $this->active_object, 'time_url' => $time_url, 'add_url' => $time_add_url, 'page_tab' => 'time', 'can_manage' => $this->logged_user->getProjectPermission('timerecord', $this->active_project) >= PROJECT_PERMISSION_MANAGE)); }
/** * Create a new reminder * * @param void * @return null */ function add() { $this->wireframe->print_button = false; $parent = ProjectObjects::findById($this->request->getId('parent_id')); if (!instance_of($parent, 'ProjectObject')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $project = $parent->getProject(); if (!instance_of($project, 'Project')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $assignees = $parent->getAssignees(); $subscribers = $parent->getSubscribers(); $commenters = Comments::findCommenters($parent, $this->logged_user); $reminder_data = $this->request->post('reminder'); if (!is_array($reminder_data)) { $who = 'user'; if (is_foreachable($assignees)) { $who = 'assignees'; } elseif (is_foreachable($subscribers)) { $who = 'subscribers'; } elseif (is_foreachable($commenters)) { $who = 'commenters'; } // if $reminder_data = array('who' => $who); } // if $this->smarty->assign(array('parent' => $parent, 'assignees' => $assignees, 'subscribers' => $subscribers, 'commenters' => $commenters, 'project_users' => ProjectUsers::findUserIdsByProject($project), 'reminder_data' => $reminder_data)); if ($this->request->isSubmitted()) { $send_to_users = null; switch ($reminder_data['who']) { case 'assignees': $send_to_users = $assignees; break; case 'subscribers': $send_to_users = $subscribers; break; case 'commenters': $send_to_users = $commenters; break; case 'user': $user_id = (int) array_var($reminder_data, 'user_id'); if ($user_id) { $user = Users::findById($user_id); if (instance_of($user, 'User')) { $send_to_users = array($user); } // if } // if break; } // switch // Do reminder if (is_foreachable($send_to_users)) { $comment = trim(array_var($reminder_data, 'comment')); if ($comment) { require_once SMARTY_PATH . '/plugins/modifier.clickable.php'; require_once ANGIE_PATH . '/classes/htmlpurifier/init.php'; $comment = strip_tags(prepare_html($comment, true)); // make sure we have clean text $comment = nl2br(smarty_modifier_clickable($comment)); // preserve breaklines and convert links } // if db_begin_work(); $reminders_sent = array(); foreach ($send_to_users as $user) { $reminder = new Reminder(); $reminder->setAttributes(array('user_id' => $user->getId(), 'object_id' => $parent->getId(), 'comment' => $comment)); $reminder->setCreatedBy($this->logged_user); $save = $reminder->save(); if ($save && !is_error($save)) { $reminders_sent[] = $user->getDisplayName(); ApplicationMailer::send($user, 'system/reminder', array('reminded_by_name' => $this->logged_user->getDisplayName(), 'reminded_by_url' => $this->logged_user->getViewUrl(), 'object_name' => $parent->getName(), 'object_url' => $parent->getViewUrl(), 'object_type' => strtolower($parent->getType()), 'comment_body' => $comment, 'project_name' => $project->getName(), 'project_url' => $project->getOverviewUrl()), $parent); } // if } // foreach db_commit(); $message = lang('Users reminded: :users', array('users' => implode(', ', $reminders_sent))); if ($this->request->get('skip_layout')) { $this->renderText($message); } else { flash_success($message); $this->redirectToUrl($parent->getViewUrl()); } // if // No reminders } else { if ($this->request->get('skip_layout')) { $this->renderText(lang('0 users reminded')); } else { flash_success('0 users reminded'); $this->redirectToUrl($parent->getViewUrl()); } // if } // if } // if }
/** * Find by commit id * * @param integer $id * @return object */ function findById($id) { return ProjectObjects::findById($id); }
/** * Get project objects affected by a commit * * @param null * @return void */ function project_object_commits() { $project_object_id = array_var($_GET, 'object_id'); $project_object = ProjectObjects::findById($project_object_id); if (!instance_of($project_object, 'ProjectObject')) { flash_error('Requested object does not exist'); $this->redirectToReferer(source_module_url($this->active_project)); } $this->wireframe->addBreadCrumb($project_object->getType() . ' ' . $project_object->getName(), $project_object->getViewUrl()); $this->smarty->assign(array('commits' => CommitProjectObjects::findCommitsByObject($project_object, $this->active_project), 'active_object' => $project_object)); }
/** * Add comment to object * */ function add_comment() { $parent_id = $this->request->get('parent_id'); $parent = ProjectObjects::findById($parent_id); if (!instance_of($parent, 'ProjectObject')) { $this->httpError(HTTP_NOT_FOUND); } // if if (!$parent->canComment($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $comment_data = $this->request->post('comment'); $this->smarty->assign(array('parent' => $parent, 'comment_data' => $comment_data, 'recent_comments' => Comments::findRecentObject($parent, 5, STATE_VISIBLE, $this->logged_user->getVisibility()), 'page_back_url' => mobile_access_module_get_view_url($parent))); $this->addBreadcrumb(ucfirst(lang($parent->getModule())), assemble_url('mobile_access_view_' . $parent->getModule(), array('project_id' => $this->active_project->getId()))); $this->addBreadcrumb($parent->getName(), mobile_access_module_get_view_url($parent)); $this->addBreadcrumb('Add Comment'); if ($this->request->isSubmitted()) { db_begin_work(); $comment = new Comment(); $comment->setAttributes($comment_data); $comment->setParent($parent); $comment->setProjectId($this->active_project->getId()); $comment->setState(STATE_VISIBLE); $comment->setVisibility($parent->getVisibility()); $comment->setCreatedBy($this->logged_user); $save = $comment->save(); if ($save && !is_error($save)) { db_commit(); flash_success('Comment successfully posted'); $this->redirectToUrl(mobile_access_module_get_view_url($comment)); } else { db_rollback(); $this->smarty->assign('errors', $save); $this->render(); } // if } // if }
/** * Return parent object * * @param void * @return ProjectObject */ function &getParent() { if ($this->parent === false) { $this->parent = $this->getParentId() ? ProjectObjects::findById($this->getParentId()) : null; } // if return $this->parent; }
/** * Show and process object subscribers page * * @param void * @return null */ function object_subscribers() { $this->skip_layout = true; $object = null; $object_id = $this->request->getId('object_id'); if ($object_id) { $object = ProjectObjects::findById($object_id); } // if if (!instance_of($object, 'ProjectObject')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $project = $object->getProject(); if (!instance_of($project, 'Project')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$object->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $this->smarty->assign(array('active_project' => $project, 'active_object' => $object)); $users = $project->getUsers(); if (is_foreachable($users)) { $people = array(); $grouped_users = array(); foreach ($users as $user) { $company_id = $user->getCompanyId(); if (!isset($people[$company_id])) { $people[$company_id] = array('users' => null, 'company' => null); } // if $people[$company_id]['users'][] = $user; } // foreach $companies = Companies::findByIds(array_keys($people)); foreach ($companies as $company) { $people[$company->getId()]['company'] = $company; } // foreach $this->smarty->assign('people', $people); } else { $this->smarty->assign('people', null); } // if }
/** * Update an existing comment * * @param void * @return null */ function edit() { $this->wireframe->print_button = false; if ($this->active_comment->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_comment->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $parent = $this->active_comment->getParent(); if (!instance_of($parent, 'ProjectObject')) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if $parent->prepareProjectSectionBreadcrumb($this->wireframe); $this->wireframe->addBreadCrumb($parent->getName(), $parent->getViewUrl()); $comment_data = $this->request->post('comment'); if (!is_array($comment_data)) { $comment_data = array('body' => $this->active_comment->getBody()); } // if $this->smarty->assign('comment_data', $comment_data); //BOF:task_1260 $active_object = ProjectObjects::findById($this->active_comment->getParentId()); $this->smarty->assign('subscribers', $active_object->getSubscribers()); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); //$query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "'"; $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "'"; $request = mysql_query($query); $fyi_users = array(); $action_request_users = array(); while ($entry = mysql_fetch_array($request)) { //BOF:mod 20130429 /* //EOF:mod 20130429 if ($entry['is_action_request']=='1'){ //BOF:mod 20130429 */ if (!empty($entry['is_action_request'])) { //EOF:mod 20130429 $action_request_users[] = $entry['user_id']; } //BOF:mod 20130429 /* //EOF:mod 20130429 if ($entry['is_fyi']=='1'){ $fyi_users[] = $entry['user_id']; } //BOF:mod 20130429 */ //EOF:mod 20130429 } $this->smarty->assign('fyi_users', $fyi_users); $this->smarty->assign('action_request_users', $action_request_users); $this->smarty->assign('logged_user', $this->logged_user); //EOF:task_1260 if ($this->request->isSubmitted()) { $this->active_comment->setAttributes($comment_data); $save = $this->active_comment->save(); if ($save && !is_error($save)) { //BOF:task_1260 //$subscribers_to_notify = array_var($comment_data, 'subscribers_to_notify'); $action_request_user_id = array_var($comment_data, 'action_request'); //mysql_query("update healingcrystals_assignments_action_request set is_action_request='0', is_fyi='0' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and is_action_request<>'-1' and is_fyi<>'-1'"); //mysql_query("update healingcrystals_assignments_action_request set is_action_request='0', is_fyi='0' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and is_action_request<>'-1' and is_fyi<>'-1'"); /*if (!empty($subscribers_to_notify)){ foreach ($subscribers_to_notify as $id){ $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $id . "'"; $result = mysql_query($query); if (mysql_num_rows($result)){ $query = "update healingcrystals_assignments_action_request set is_fyi='1' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $id . "'"; mysql_query($query); } else { $query = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added) values ('" . $id . "', '0', '1', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now())"; mysql_query($query); } } }*/ $existing_ar_users = array(); $new_ar_users = array(); if (!empty($action_request_user_id)) { foreach ($action_request_user_id as $id) { $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'"; $result = mysql_query($query); if (mysql_num_rows($result)) { $info = mysql_fetch_assoc($result); if ($info['is_action_request'] == '1') { $existing_ar_users[] = $id; } else { $query = "update healingcrystals_assignments_action_request set is_action_request='1' where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'"; mysql_query($query); $new_ar_users[] = $id; } } else { $query = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added) values ('" . $id . "', '1', '0', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now())"; mysql_query($query); $new_ar_users[] = $id; } } $query = "update healingcrystals_assignments_action_request set is_action_request='0' where comment_id='" . $this->active_comment->getId() . "' and user_id not in (" . implode(', ', $action_request_user_id) . ")"; mysql_query($query); } else { $query = "update healingcrystals_assignments_action_request set is_action_request='0' where comment_id='" . $this->active_comment->getId() . "'"; mysql_query($query); } mysql_query("delete from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and is_action_request='0' and is_fyi='0' and marked_for_email='0'"); //EOF:task_1260 foreach ($action_request_users as $id) { if (!in_array($id, $existing_ar_users)) { //unassign $query = "select object_id from actionrequests_to_tasklist where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "' and type='Task'"; $result = mysql_query($query); if (mysql_num_rows($result)) { $info = mysql_fetch_assoc($result); $task = new Task($info['object_id']); $task->delete(); mysql_query("delete from actionrequests_to_tasklist where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "' and type='Task'"); } } } foreach ($new_ar_users as $id) { //assign //BOF:mod 20130429 /* //EOF:mod 20130429 $priority = '0'; $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'"; $result = mysql_query($query, $link); if (mysql_num_rows($result)){ $query1 = "update healingcrystals_assignments_action_request set is_action_request='1', priority_actionrequest='" . $priority . "' where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'"; mysql_query($query1, $link); } else { $query1 = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added, priority_actionrequest) values ('" . $id . "', '1', '0', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now(), '" . $priority . "')"; mysql_query($query1, $link); } //BOF:mod 20130429 */ //EOF:mod 20130429 $task = new Task(); $task->setProjectId(TASK_LIST_PROJECT_ID); $task->setParentId(Page::getTaskPageIdForUser($id)); $task->setParentType('Page'); $task->setCreatedBy($this->logged_user); $task->setVisibility(VISIBILITY_NORMAL); $task->setState(STATE_VISIBLE); $task_body = ''; $parent = $this->active_comment->getParent(); $url = $parent->getViewUrl() . '#comment' . $this->active_comment->getId(); $comment_body = $this->active_comment->getBody(); $comment_body = strip_tags($comment_body); if (strlen($comment_body) > 525) { $task_body .= substr($comment_body, 0, 525) . '..'; } else { $task_body .= $comment_body; } $task_body .= '<br/><a href="' . $url . '">View Task in Full</a>'; $attachments = $this->active_comment->getAttachments(); if (is_foreachable($attachments)) { $task_body .= '<br/>Attachments:<br/>'; foreach ($attachments as $attachment) { $task_body .= '<a href="' . $attachment->getViewUrl() . '">' . $attachment->getName() . '</a><br/>'; } } $task->setBody($task_body); $savetask = $task->save(); if ($savetask && !is_error($savetask)) { $task->ready(); mysql_query("insert into actionrequests_to_tasklist (comment_id, user_id, type, object_id) values ('" . $this->active_comment->getId() . "', '" . $id . "', 'Task', '" . $task->getId() . "')"); } } if ($this->request->getFormat() == FORMAT_HTML) { flash_success('Comment has been updated'); $this->redirectToUrl($this->active_comment->getRealViewUrl()); } else { $this->serveData($this->active_comment, 'comment'); } // if } else { if ($this->request->getFormat() == FORMAT_HTML) { $this->smarty->assign('errors', $save); } else { $this->serveData($save); } // if } // if } // if //BOF:task_1260 //mysql_close($link); //EOF:task_1260 }
/** * Toggles object completed state * */ function toggle_completed() { $object_id = (int) $this->request->get('object_id'); if ($object_id) { $object = ProjectObjects::findById($object_id); } else { $object = new ProjectObject(); } // if if ($object->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if ($object->isCompleted()) { $object->open($this->logged_user); } else { $object->complete($this->logged_user); } $this->redirectToUrl(mobile_access_module_get_view_url($object)); }
/** * Return associative array of changes that is easy to display * * @param void * @return array */ function getVerboseChanges() { $result = array(); if (is_foreachable($this->getChanges())) { foreach ($this->getChanges() as $field => $change_data) { list($old_value, $new_value) = $change_data; $log_fields = array('project_id', 'milestone_id', 'parent_id', 'name', 'body', 'priority', 'due_on'); switch ($field) { case 'project_id': $old_project = Projects::findById($old_value); $new_project = Projects::findById($new_value); $old_project_name = instance_of($old_project, 'Project') ? $old_project->getName() : lang('unknown project'); $new_project_name = instance_of($new_project, 'Project') ? $new_project->getName() : lang('unknown project'); $result[] = lang('Moved from <span>:from</span> to <span>:to</span>', array('from' => $old_project_name, 'to' => $new_project_name)); break; case 'milestone_id': $old_milestone = Milestones::findById($old_value); $new_milestone = Milestones::findById($new_value); $old_milestone_name = instance_of($old_milestone, 'Milestone') ? $old_milestone->getName() : lang('-- none --'); $new_milestone_name = instance_of($new_milestone, 'Milestone') ? $new_milestone->getName() : lang('-- none --'); $result[] = lang('Moved from <span>:from</span> to <span>:to</span> milestone', array('from' => $old_milestone_name, 'to' => $new_milestone_name)); break; case 'parent_id': $old_parent = ProjectObjects::findById($old_value); $new_parent = ProjectObjects::findById($new_value); $old_parent_name = instance_of($old_parent, 'Category') ? $old_parent->getName() : lang('-- none --'); $new_parent_name = instance_of($new_parent, 'Category') ? $new_parent->getName() : lang('-- none --'); $result[] = lang('Moved from <span>:from</span> to <span>:to</span> category', array('from' => $old_parent_name, 'to' => $new_parent_name)); break; case 'name': $result[] = lang('Summary is changed from <span>:from</span> to <span>:to</span>', array('from' => $old_value, 'to' => $new_value)); break; case 'body': $result[] = lang('Long description is changed'); break; case 'priority': switch ($old_value) { case PRIORITY_HIGHEST: $old_priority = lang('Highest'); break; case PRIORITY_HIGH: $old_priority = lang('High'); break; case PRIORITY_NORMAL: $old_priority = lang('Normal'); break; case PRIORITY_LOW: $old_priority = lang('Low'); break; case PRIORITY_LOWEST: $old_priority = lang('Lowest'); break; case PRIORITY_ONGOING: $old_priority = lang('Ongoing'); break; case PRIORITY_HOLD: $old_priority = lang('Hold'); break; } // switch switch ($new_value) { case PRIORITY_HIGHEST: $new_priority = lang('Highest'); break; case PRIORITY_HIGH: $new_priority = lang('High'); break; case PRIORITY_NORMAL: $new_priority = lang('Normal'); break; case PRIORITY_LOW: $new_priority = lang('Low'); break; case PRIORITY_LOWEST: $new_priority = lang('Lowest'); break; case PRIORITY_ONGOING: $new_priority = lang('Ongoing'); break; case PRIORITY_HOLD: $new_priority = lang('Hold'); break; } // switch $result[] = lang('Priority is changed from <span>:from</span> to <span>:to</span>', array('from' => $old_priority, 'to' => $new_priority)); break; case 'due_on': require_once SMARTY_PATH . '/plugins/modifier.date.php'; $old_due_on = instance_of($old_value, 'DateValue') ? smarty_modifier_date($old_value, 0) : lang('-- none --'); $new_due_on = instance_of($new_value, 'DateValue') ? smarty_modifier_date($new_value, 0) : lang('-- none --'); $result[] = lang('Due date is changed from <span>:from</span> to <span>:to</span>', array('from' => $old_due_on, 'to' => $new_due_on)); break; case 'completed_on': if (instance_of($old_value, 'DateValue') && $new_value === null) { $result[] = lang('Status changed to: Open'); } elseif ($old_value === null && instance_of($new_value, 'DateValue')) { $result[] = lang('Status changed to: Completed'); } // if break; case 'owner': if ($new_value) { $new_owner = Users::findById($new_value); if (instance_of($new_owner, 'User')) { $result[] = lang(':user is responsible', array('user' => $new_owner->getDisplayName())); } else { $result[] = lang('Owner changed (unknown user or deleted in the meantime)'); } // if } else { $result[] = lang('Anyone can pick up and work on this ticket'); } // if break; case 'assignees': $old_assignees = array(); if (is_foreachable($old_value)) { $old_assignees_users = Users::findByIds($old_value); if (is_foreachable($old_assignees_users)) { foreach ($old_assignees_users as $user) { $old_assignees[$user->getId()] = $user->getDisplayName(); } // foreach } // if } // if $new_assignees = array(); if (is_foreachable($new_value)) { $new_assignees_users = Users::findByIds($new_value); if (is_foreachable($new_assignees_users)) { foreach ($new_assignees_users as $user) { $new_assignees[$user->getId()] = $user->getDisplayName(); } // foreach } // if } // if foreach ($new_assignees as $new_assignee_id => $new_assignee) { if (!array_key_exists($new_assignee_id, $old_assignees)) { $result[] = lang(':user has been assigned to this ticket', array('user' => $new_assignee)); } // if } // foreach foreach ($old_assignees as $old_assignee_id => $old_assignee) { if (!array_key_exists($old_assignee_id, $new_assignees)) { $result[] = lang(':user has been removed from this ticket', array('user' => $old_assignee)); } // if } // foreach break; } // switch } // foreach } // if return $result; }
function importPendingEmailAsComment(&$incoming_mail, &$project, &$user, &$mailbox, $page_id = '') { $parent = ProjectObjects::findById(!empty($page_id) ? $page_id : $incoming_mail->getParentId()); //EOF:mod 20120820 if (!instance_of($parent, 'ProjectObject')) { // parent object does not exists $incoming_mail->setState(INCOMING_MAIL_STATUS_PARENT_NOT_EXISTS); $incoming_mail_save = $incoming_mail->save(); return new Error(incoming_mail_module_get_status_description(INCOMING_MAIL_STATUS_PARENT_NOT_EXISTS)); } // if if (!$mailbox->getAcceptAllRegistered() && instance_of($user, 'User') && !$parent->canComment($user)) { // user cannot create comments to parent object $incoming_mail->setState(INCOMING_MAIL_STATUS_USER_CANNOT_CREATE_COMMENT); $incoming_mail_save = $incoming_mail->save(); return new Error(incoming_mail_module_get_status_description(INCOMING_MAIL_STATUS_USER_CANNOT_CREATE_COMMENT)); } else { if (!$parent->can_have_comments || $parent->getIsLocked() || $parent->getState() < STATE_VISIBLE) { // parent object can't have comments $incoming_mail->setState(INCOMING_MAIL_STATUS_USER_CANNOT_CREATE_COMMENT); $incoming_mail_save = $incoming_mail->save(); return new Error(incoming_mail_module_get_status_description(INCOMING_MAIL_STATUS_USER_CANNOT_CREATE_COMMENT)); } // if } // if $comment = new Comment(); $comment->log_activities = false; $comment->setCreatedBy($user); $comment->setCreatedOn($incoming_mail->getCreatedOn()); $comment->setProjectId($parent->getProjectId()); $comment->setState(STATE_VISIBLE); $comment->setSource(OBJECT_SOURCE_EMAIL); $comment->setVisibility($parent->getVisibility()); $comment->setParent($parent); $body_content = ''; if (stripos($incoming_mail->getBody(), '-- REPLY ABOVE THIS LINE --') !== false) { $body_content = substr($incoming_mail->getBody(), 0, strpos($incoming_mail->getBody(), '-- REPLY ABOVE THIS LINE --')); } else { $body_content = $incoming_mail->getBody(); } $comment->setBody($body_content); IncomingMailImporter::attachFilesToProjectObject($incoming_mail, $comment); //$save = $comment->save(); $save = $comment->save(true); if ($save && !is_error($save)) { $activity = new NewCommentActivityLog(); $activity->log($comment, $user); if (instance_of($user, 'User')) { $parent->subscribe($user); } // if $comment->ready(); //BOF:mod 20111110 #493 preg_match("/\\[CID(.*?)\\](.*)/is", $incoming_mail->getSubject(), $results); if (count($results) > 0) { $project = new Project($parent->getProjectId()); $variables = array('owner_company_name' => get_owner_company(), 'project_name' => $project->getName(), 'project_url' => $project->getOverviewUrl(), 'object_type' => $comment->getVerboseType(), 'object_name' => $comment->getName(), 'object_body' => $comment->getFormattedBody(), 'object_url' => $comment->getViewUrl(), 'comment_body' => $comment->getFormattedBody(), 'comment_url' => $comment->getViewUrl(), 'created_by_url' => $user->getViewUrl(), 'created_by_name' => $user->getDisplayName(), 'details_body' => '', 'comment_id' => $comment->getId()); $emailed_comment_id = $results[1]; $emailed_comment = new Comment($emailed_comment_id); $emailed_comment_creator_id = $emailed_comment->getCreatedById(); $email_to = array(); $temp_user_id = $user->getId(); $temp_comment_id = $comment->getId(); $rows = db_execute_all("select user_id from " . TABLE_PREFIX . "assignments_action_request where comment_id='" . $emailed_comment_id . "' and marked_for_email='1'"); foreach ($rows as $row) { if ($row['user_id'] != $temp_user_id) { $email_to[] = new User($row['user_id']); db_execute("insert into " . TABLE_PREFIX . "assignments_action_request (user_id, marked_for_email, selected_by_user_id, comment_id, date_added) values ('" . $row['user_id'] . "', '1', '" . $temp_user_id . "', '" . $temp_comment_id . "', now())"); } } $row = db_execute_one("select a.selected_by_user_id from " . TABLE_PREFIX . "assignments_action_request a where a.comment_id='" . $emailed_comment_id . "' and a.marked_for_email='1' and a.selected_by_user_id not in (select b.user_id from " . TABLE_PREFIX . "assignments_action_request b where b.comment_id='" . $emailed_comment_id . "' and b.marked_for_email='1') limit 0, 1"); if (!empty($row['selected_by_user_id'])) { if ($row['selected_by_user_id'] != $temp_user_id) { $email_to[] = new User($row['selected_by_user_id']); db_execute("insert into " . TABLE_PREFIX . "assignments_action_request (user_id, marked_for_email, selected_by_user_id, comment_id, date_added) values ('" . $row['selected_by_user_id'] . "', '1', '" . $temp_user_id . "', '" . $temp_comment_id . "', now())"); } } //ApplicationMailer::send(array(new User($emailed_comment_creator_id)), 'resources/new_comment', $variables, $parent); $attachments = null; $object_attachments = $comment->getAttachments(); if ($object_attachments) { $attachments = array(); foreach ($object_attachments as $object_attachment) { $attachments[] = array('path' => $object_attachment->getFilePath(), 'name' => $object_attachment->getName(), 'mime_type' => $object_attachment->getMimeType()); } } ApplicationMailer::send($email_to, 'resources/new_comment', $variables, $parent, $attachments); } //EOF:mod 20111110 #493 if (!empty($page_id)) { //$link = mysql_connect(DB_HOST, DB_USER, DB_PASS); //mysql_select_db(DB_NAME, $link); //mysql_query("insert into testing (date_added, content) values (now(), 'Page_id: " . $page_id . "')"); //mysql_close($link); $task =& IncomingMailImporter::importPendingEmailToTaskList($incoming_mail, $project, $user, $page_id, $comment); return $task; } else { return $comment; } } // if return $save; }