/**
  * 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'));
 }
/**
 * Render select parent object for provided project
 * 
 * Supported paramteres:
 * 
 * - types - type of of parent objects to be listed
 * - project - Instance of selected project (required)
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_project_object($params, &$smarty)
{
    $project = array_var($params, 'project');
    if (!instance_of($project, 'Project')) {
        return new InvalidParamError('project', $project, '$project is expected to be an instance of Project class', true);
    }
    // if
    $value = array_var($params, 'value');
    unset($params['project']);
    $types = array_var($params, 'types', null);
    if (!$types || !is_foreachable($types = explode(',', $types))) {
        $types = array('ticket', 'file', 'discussion', 'page');
    }
    // if
    $id_name_map = ProjectObjects::getIdNameMapForProject($project, $types);
    if (!is_foreachable($id_name_map)) {
        return false;
    }
    // if
    $sorted = array();
    foreach ($id_name_map as $object) {
        $option_attributes = $value == $object['id'] ? array('selected' => true) : null;
        $sorted[strtolower($object['type'])][] = option_tag($object['name'], $object['id'], $option_attributes);
    }
    // foreach
    if (is_foreachable($sorted)) {
        foreach ($sorted as $sorted_key => $sorted_values) {
            $options[] = option_group_tag($sorted_key, $sorted_values);
        }
        // foreach
    }
    // if
    return select_box($options, $params);
}
 /**
  * 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'));
 }
Exemplo n.º 4
0
 /**
  * Return related object
  *
  * @param void
  * @return ProjectObject
  */
 function getObject()
 {
     if ($this->object === false) {
         $this->object = ProjectObjects::findById($this->getObjectId());
     }
     // if
     return $this->object;
 }
 /**
  * Return repository which was first added and last commit info
  *
  * @param Project $project
  * @return array
  */
 function findByPortalProject($project)
 {
     $repository = ProjectObjects::find(array('conditions' => array('project_id = ? AND type = ? AND state >= ?', $project->getId(), 'Repository', STATE_VISIBLE), 'order' => 'created_on ASC', 'one' => true));
     if (instance_of($repository, 'Repository')) {
         $repository->last_commit = $repository->getLastCommit();
     }
     // if
     return $repository;
 }
 /**
  * Show calendar day
  *
  * @param void
  * @return null
  */
 function day()
 {
     if ($this->request->get('year') && $this->request->get('month') && $this->request->get('day')) {
         $day = new DateValue($this->request->get('year') . '-' . $this->request->get('month') . '-' . $this->request->get('day'));
     } else {
         $day = DateValue::now();
     }
     // if
     $this->wireframe->addBreadCrumb($day->getYear() . ' / ' . $day->getMonth(), Calendar::getDashboardMonthUrl($day->getYear(), $day->getMonth()));
     $objects = ProjectObjects::groupByProject(Calendar::getActiveProjectsDayData($this->logged_user, $day));
     $this->smarty->assign(array('day' => $day, 'groupped_objects' => $objects));
 }
 /**
  * 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;
 }
 /**
  * Show single tag
  *
  * @param void
  * @return null
  */
 function view()
 {
     $tag = urldecode($this->request->get('tag'));
     $tags = Tags::buildIndex($this->active_project);
     $per_page = 30;
     $page = (int) $this->request->get('page');
     if ($page < 1) {
         $page = 1;
     }
     // if
     list($objects, $pagination) = ProjectObjects::paginateByIds($tags[$tag]['objects'], $page, $per_page, STATE_VISIBLE, $this->logged_user->getVisibility());
     $this->smarty->assign(array('tag' => $tag, 'objects' => $objects, 'pagination' => $pagination, 'tag_url_pattern' => Tags::getTagUrl($tag, $this->active_project, '-PAGE-')));
 }
/**
 * Handle on_dashboard_sections event
 *
 * @param NamedList $sections
 * @param User $user
 * @return null
 */
function system_handle_on_dashboard_sections(&$sections, &$user)
{
    $sections->add('recent_activities', array('text' => lang('Recent Activities'), 'url' => assemble_url('recent_activities')));
    $sections->add('active_projects', array('text' => lang('Active Projects'), 'url' => assemble_url('active_projects')));
    $count_new = ProjectObjects::countNew($user);
    if ($count_new > 0) {
        $sections->add('new_updated', array('text' => lang('New / Updated <span class="slip">:count</span>', array('count' => $count_new)), 'url' => assemble_url('new_since_last_visit')));
    }
    // if
    $count_late_today = ProjectObjects::countLateAndToday($user, null, get_completable_project_object_types());
    if ($count_late_today > 0) {
        $sections->add('late_today', array('text' => lang('Late / Today <span class="slip">:count</span>', array('count' => $count_late_today)), 'url' => assemble_url('late_today')));
    }
    // if
}
 /**
  * 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));
 }
 /**
  * Return paginated set of project objects
  *
  * @param array $arguments
  * @param itneger $page
  * @param integer $per_page
  * @return array
  */
 function paginate($arguments = null, $page = 1, $per_page = 10)
 {
     if (!is_array($arguments)) {
         $arguments = array();
     }
     // if
     $arguments['limit'] = $per_page;
     $arguments['offset'] = ($page - 1) * $per_page;
     $items = ProjectObjects::findBySQL(DataManager::prepareSelectFromArguments($arguments, TABLE_PREFIX . 'project_objects'), null, array_var($arguments, 'one'));
     $total_items = ProjectObjects::count(array_var($arguments, 'conditions'));
     return array($items, new Pager($page, $total_items, $per_page));
 }
 /**
  * Return starred project objects by $user
  *
  * @param User $user
  * @return array
  */
 function findByUser($user)
 {
     $project_objects_table = TABLE_PREFIX . 'project_objects';
     $starred_objects_table = TABLE_PREFIX . 'starred_objects';
     if ($user->isProjectManager()) {
         return ProjectObjects::findBySQL("SELECT {$project_objects_table}.* FROM {$project_objects_table}, {$starred_objects_table} WHERE {$starred_objects_table}.object_id = {$project_objects_table}.id AND {$starred_objects_table}.user_id = ? AND {$project_objects_table}.state >= ? ORDER BY {$project_objects_table}.priority DESC", array($user->getId(), STATE_VISIBLE));
     } else {
         $type_filter = ProjectUsers::getVisibleTypesFilter($user, array(PROJECT_STATUS_ACTIVE, PROJECT_STATUS_PAUSED, PROJECT_STATUS_CANCELED, PROJECT_STATUS_COMPLETED));
         if ($type_filter) {
             return ProjectObjects::findBySQL("SELECT {$project_objects_table}.* FROM {$project_objects_table}, {$starred_objects_table} WHERE {$type_filter} AND {$starred_objects_table}.object_id = {$project_objects_table}.id AND {$starred_objects_table}.user_id = ? AND {$project_objects_table}.state >= ? AND {$project_objects_table}.visibility >= ? ORDER BY {$project_objects_table}.priority DESC", array($user->getId(), STATE_VISIBLE, $user->getVisibility()));
         }
         // if
     }
     // if
     return null;
 }
 /**
  * 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
 }
Exemplo n.º 19
0
 /**
  * Return all milestones for a given portal project
  *
  * @param Portal $portal
  * @param Project $project
  * @return array
  */
 function findByPortalProject($portal, $project)
 {
     if ($portal->getProjectPermissionValue('milestone') >= PROJECT_PERMISSION_ACCESS) {
         return ProjectObjects::find(array('conditions' => array('project_id = ? AND type = ? AND state >= ? AND visibility >= ?', $project->getId(), 'Milestone', STATE_VISIBLE, VISIBILITY_NORMAL), 'order' => 'name'));
     }
     // if
     return null;
 }
 /**
  * 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));
 }
 /**
  * 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));
 }
 /**
  * Export project pages
  *
  * @param void
  * @return null
  */
 function export()
 {
     $object_visibility = array_var($_GET, 'visibility', VISIBILITY_NORMAL);
     $exportable_modules = explode(',', array_var($_GET, 'modules', null));
     if (!is_foreachable($exportable_modules)) {
         $exportable_modules = null;
     }
     // if
     require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php';
     $output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, $this->active_module, $exportable_modules);
     if (!$output_builder->createOutputFolder()) {
         $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON);
     }
     // if
     $output_builder->createAttachmentsFolder();
     $module_categories = Categories::findByModuleSection($this->active_project, PAGES_MODULE, 'pages');
     $output_builder->smarty->assign(array('categories' => $module_categories, 'visibility' => $object_visibility));
     $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'index');
     $output_builder->outputToFile('index');
     if (is_foreachable($module_categories)) {
         foreach ($module_categories as $module_category) {
             $output_builder->smarty->assign('current_category', $module_category);
             $output_builder->smarty->assign('objects', Pages::findByCategory($module_category, STATE_VISIBLE, $object_visibility));
             $output_builder->outputToFile('category_' . $module_category->getId());
         }
         // foreach
     }
     // if
     $pages = ProjectObjects::find(array("conditions" => array("project_id = ? AND module = ? AND type = ?", $this->active_project->getId(), 'pages', 'Page')));
     $page_ids = array();
     if (is_foreachable($pages)) {
         $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'object');
         foreach ($pages as $page) {
             if (instance_of($page, 'Page')) {
                 $page_ids[] = $page->getId();
                 $parent = $page->getParent();
                 $comments = $page->getComments($object_visibility);
                 $output_builder->smarty->assign(array('page' => $page, 'subpages' => $page->getSubpages($object_visibility), 'parent' => $parent, 'comments' => $comments));
                 if (instance_of($parent, 'Page')) {
                     $output_builder->smarty->assign('parent_url', './page_' . $parent->getId() . '.html');
                 } else {
                     if (instance_of($parent, 'Category')) {
                         $output_builder->smarty->assign('parent_url', './category_' . $parent->getId() . '.html');
                     }
                 }
                 // if
                 $output_builder->outputToFile('page_' . $page->getId());
                 $output_builder->outputObjectsAttachments($comments);
                 $output_builder->outputAttachments($page->getAttachments());
             }
             // if
         }
         // foreach
         $revisions = PageVersions::findByPageIds($page_ids);
         if (is_foreachable($revisions)) {
             $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'revision');
             foreach ($revisions as $revision) {
                 $output_builder->smarty->assign('revision', $revision);
                 $output_builder->outputToFile('revision_' . $revision->getPageId() . '_' . $revision->getVersion());
             }
             // foreach
         }
         // if
     }
     // if
     $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON);
 }
Exemplo n.º 23
0
 /**
  * Delete project and all realted data
  *
  * @param void
  * @return null
  */
 function delete()
 {
     db_begin_work();
     $delete = parent::delete();
     if ($delete && !is_error($delete)) {
         ProjectObjects::deleteByProject($this);
         ProjectUsers::deleteByProject($this);
         PinnedProjects::deleteByProject($this);
         search_index_remove($this->getId(), 'Project');
         clean_project_permissions_cache($this);
         event_trigger('on_project_deleted', array($this));
         db_commit();
     } else {
         db_rollback();
     }
     // if
     return $delete;
 }
 /**
  * Find # of a timerecord in a project
  *
  * @param Timerecord $timerecord
  * @param integer $min_state
  * @param integer $min_visiblity
  * @return integer
  */
 function findTimerecordNum($timerecord, $min_state = STATE_VISIBLE, $min_visiblity = VISIBILITY_NORMAL)
 {
     return ProjectObjects::count(array("type = 'Timerecord' AND date_field_1 > ? AND project_id = ? AND state >= ? AND visibility >= ?", $timerecord->getRecordDate(), $timerecord->getProjectId(), $min_state, $min_visiblity)) + 1;
 }
 /**
  * attachments_mass_update
  *
  * @param void
  * @return null
  */
 function attachments_mass_update()
 {
     if (!$this->active_object->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
     }
     // if
     if ($this->request->isSubmitted()) {
         $action = $this->request->post('action');
         if (!in_array($action, array('move_to_trash'))) {
             $this->httpError(HTTP_ERR_BAD_REQUEST, 'Invalid action');
         }
         // if
         $objects = ProjectObjects::findByIds($this->request->post('objects'));
         $operations_performed = 0;
         foreach ($objects as $object) {
             if ($action == 'move_to_trash') {
                 $operation = $object->moveToTrash();
             }
             // if
             if ($operation && !is_error($operation)) {
                 $operations_performed++;
             }
             // if
         }
         // foreach
         db_commit();
         if ($action == 'move_to_trash') {
             $message = lang(':count objects moved to trash', array('count' => $operations_performed));
         }
         // if
         flash_success($message, null, true);
         $this->redirectToUrl($this->active_object->getAttachmentsUrl());
     }
     // if
 }
 /**
  * Export discussions
  *
  * @param void
  * @return null
  */
 function export()
 {
     $object_visibility = array_var($_GET, 'visibility', VISIBILITY_NORMAL);
     $exportable_modules = explode(',', array_var($_GET, 'modules', null));
     if (!is_foreachable($exportable_modules)) {
         $exportable_modules = null;
     }
     // if
     require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php';
     $output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, $this->active_module, $exportable_modules);
     if (!$output_builder->createOutputFolder()) {
         $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON);
     }
     // if
     $output_builder->createAttachmentsFolder();
     $module_objects = Discussions::findByProject($this->active_project, STATE_VISIBLE, $object_visibility);
     $module_categories = Categories::findByModuleSection($this->active_project, $this->active_module, $this->active_module);
     $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'index');
     $output_builder->smarty->assign('categories', $module_categories);
     $output_builder->smarty->assign('objects', $module_objects);
     $output_builder->outputToFile('index');
     // export files by categories
     if (is_foreachable($module_categories)) {
         foreach ($module_categories as $module_category) {
             if (instance_of($module_category, 'Category')) {
                 $objects = ProjectObjects::find(array('conditions' => array('parent_id = ? AND project_id = ? AND type = ? AND state >= ? AND visibility >= ?', $module_category->getId(), $this->active_project->getId(), 'Discussion', STATE_VISIBLE, $object_visibility), 'order' => 'boolean_field_1, datetime_field_1 DESC'));
                 $output_builder->smarty->assign(array('current_category' => $module_category, 'objects' => $objects));
                 $output_builder->outputToFile('category_' . $module_category->getId());
             }
             // if
         }
         // foreach
     }
     // if
     // export discussions
     if (is_foreachable($module_objects)) {
         $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'object');
         foreach ($module_objects as $module_object) {
             if (instance_of($module_object, 'Discussion')) {
                 $comments = $module_object->getComments($object_visibility);
                 $output_builder->smarty->assign(array('object' => $module_object));
                 $output_builder->smarty->assign('comments', $comments);
                 $output_builder->outputToFile('discussion_' . $module_object->getId());
                 $output_builder->outputObjectsAttachments($comments);
                 $output_builder->outputAttachments($module_object->getAttachments());
             }
             // if
         }
         // foreach
     }
     // if
     $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON);
 }
Exemplo n.º 27
0
 /**
  * Return categories for module section (ex. attachments of resources module)
  *
  * @param Project $project
  * @param string $module
  * @param string $controller
  * @return array
  */
 function findByModuleSection($project, $module, $controller)
 {
     return ProjectObjects::find(array('conditions' => array('type = ? AND project_id = ? AND module = ? AND state >= ? AND varchar_field_1 = ?', 'Category', $project->getId(), $module, STATE_VISIBLE, $controller), 'order' => 'name'));
 }
 /**
  * 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;
 }
Exemplo n.º 29
0
 /**
  * Return data for a given day
  *
  * @param DateValue $day
  * @param string $additional_conditions
  * @param boolean $include_assignments_table
  * @return array
  */
 function getDayData($day, $additional_conditions, $include_assignments_table = false)
 {
     $objects_table = TABLE_PREFIX . 'project_objects';
     $assignments_table = TABLE_PREFIX . 'assignments';
     $conditions = db_prepare_string("{$objects_table}.due_on = ?", array($day));
     if ($additional_conditions) {
         $conditions .= " AND {$additional_conditions}";
     }
     // if
     // If we don't have user ID-s filter we can exclude assignments table
     $tables = $include_assignments_table ? "{$objects_table}, {$assignments_table}" : $objects_table;
     return ProjectObjects::findBySQL("SELECT DISTINCT {$objects_table}.* FROM {$tables} WHERE {$conditions} ORDER BY priority DESC");
 }
 /**
  * Serve iCal data
  *
  * @param void
  * @return null
  */
 function ical()
 {
     if ($this->active_project->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $filter = ProjectUsers::getVisibleTypesFilterByProject($this->logged_user, $this->active_project, get_completable_project_object_types());
     if ($filter) {
         $objects = ProjectObjects::find(array('conditions' => array($filter . ' AND completed_on IS NULL AND state >= ? AND visibility >= ?', STATE_VISIBLE, $this->logged_user->getVisibility()), 'order' => 'priority DESC'));
         render_icalendar($this->active_project->getName() . ' ' . lang('calendar'), $objects);
         die;
     } else {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
 }