コード例 #1
0
 /**
  * Show a list of all the comment posts.
  *
  * @return View
  */
 public function index()
 {
     // Grab all the comment posts
     $comments = $this->commentRepository->getAll();
     // Show the page
     $this->render('admin.comments.index', compact('comments'));
 }
コード例 #2
0
 public function view()
 {
     $thread = Thread::getById(Param::get('thread_id'));
     $page = Param::get('page', 1);
     $pagination = new SimplePagination($page, self::MAX_ITEM_PER_PAGE);
     $filter_username = htmlentities(Param::get('username'));
     $comments = Comment::getAll($pagination->start_index - 1, $pagination->count + 1, $thread->id, $filter_username);
     $pagination->checkLastPage($comments);
     Comment::getUserAttributes($comments, $_SESSION['userid']);
     Comment::sortByLikes($comments, Param::get('sort'));
     $total = Comment::countAll();
     $pages = ceil($total / self::MAX_ITEM_PER_PAGE);
     $this->set(get_defined_vars());
 }
コード例 #3
0
 public function view()
 {
     // get total number of pages
     $thread = Thread::get(Param::get('id'));
     $total = Comment::countAll($thread->id);
     $pages = ceil($total / self::COMMENTS_PERPAGE);
     $page = Param::get('page', 1);
     // go to last page
     if ($page == self::LAST_PAGE) {
         $page = $pages;
     }
     // paginate comments
     $pagination = new SimplePagination($page, self::COMMENTS_PERPAGE);
     $comments = Comment::getAll($thread->id, $pagination->start_index - 1, $pagination->count + 1);
     $pagination->checkLastPage($comments);
     // set other variables needed by the view
     $auth_user = User::getAuthenticated();
     $title = $thread->title;
     $this->set(get_defined_vars());
 }
コード例 #4
0
 /**
  * @depends testGetUnreadConversationCount
  */
 public function testDeleteConversation()
 {
     $conversations = Conversation::getAll();
     $this->assertEquals(3, count($conversations));
     $comments = Comment::getAll();
     $this->assertEquals(4, count($comments));
     //check count of conversation_items
     $count = ZurmoRedBean::getRow('select count(*) count from conversation_item');
     $this->assertEquals(2, $count['count']);
     //remove the account, tests tthat ConversationObserver is correctly removing data from conversation_item
     $accounts = Account::getByName('anAccount2');
     $this->assertTrue($accounts[0]->delete());
     $count = ZurmoRedBean::getRow('select count(*) count from conversation_item');
     $this->assertEquals(1, $count['count']);
     foreach ($conversations as $conversation) {
         $conversationId = $conversation->id;
         $conversation->forget();
         $conversation = Conversation::getById($conversationId);
         $deleted = $conversation->delete();
         $this->assertTrue($deleted);
     }
     //Count of conversation items should be 0 since the ConversationsObserver should make sure it gets removed correctly.
     $count = ZurmoRedBean::getRow('select count(*) count from conversation_item');
     $this->assertEquals(0, $count['count']);
     //check that all comments are removed, since they are owned.
     $comments = Comment::getAll();
     $this->assertEquals(0, count($comments));
 }
コード例 #5
0
ファイル: MissionTest.php プロジェクト: youprofit/Zurmo
 /**
  * @depends testAddingComments
  */
 public function testDeleteMission()
 {
     $missions = Mission::getAll();
     $comments = Comment::getAll();
     $personsWhoHaveNotReadLatest = PersonWhoHaveNotReadLatest::getAll();
     $this->assertGreaterThan(0, count($missions));
     $this->assertGreaterThan(0, count($comments));
     $this->assertGreaterThan(0, count($personsWhoHaveNotReadLatest));
     foreach ($missions as $mission) {
         $missionId = $mission->id;
         $mission->forget();
         $mission = Mission::getById($missionId);
         $deleted = $mission->delete();
         $this->assertTrue($deleted);
     }
     //check that all comments and personsWhoHaveNotReadLatest are removed, since they are owned.
     $comments = Comment::getAll();
     $this->assertEquals(0, count($comments));
     $missions = Mission::getAll();
     $this->assertEquals(0, count($missions));
     $personsWhoHaveNotReadLatest = PersonWhoHaveNotReadLatest::getAll();
     $this->assertEquals(0, count($personsWhoHaveNotReadLatest));
 }
コード例 #6
0
 /**
  * @depends testAddingComments
  */
 public function testDeleteSocialItem()
 {
     $socialItems = SocialItem::getAll();
     $this->assertEquals(1, count($socialItems));
     $comments = Comment::getAll();
     $this->assertEquals(1, count($comments));
     $fileModels = FileModel::getAll();
     $this->assertEquals(1, count($fileModels));
     foreach ($socialItems as $socialItem) {
         $socialItemId = $socialItem->id;
         $socialItem->forget();
         $socialItem = SocialItem::getById($socialItemId);
         $deleted = $socialItem->delete();
         $this->assertTrue($deleted);
     }
     $socialItems = SocialItem::getAll();
     $this->assertEquals(0, count($socialItems));
     //check that all comments are removed, since they are owned.
     $comments = Comment::getAll();
     $this->assertEquals(0, count($comments));
     $fileModels = FileModel::getAll();
     $this->assertEquals(0, count($fileModels));
 }
コード例 #7
0
 static function getChangeLines($query_options)
 {
     global $PH;
     global $auth;
     fillMissingValues($query_options, array('alive_only' => false));
     $date_compare = isset($query_options['date_min']) ? $query_options['date_min'] : "0000-00-00";
     /**
      * get list of items touched by other people
      */
     $changed_items = DbProjectItem::getAll($query_options);
     /**
      * go through list
      */
     $changes = array();
     foreach ($changed_items as $i) {
         $change_type = NULL;
         if (!isset($query_options['project'])) {
             $project = Project::getVisibleById($i->project);
         } else {
             $project = NULL;
         }
         /**
          * get item-change-type depeding on dates
          */
         if ($i->deleted >= $i->modified) {
             $change_type = ITEM_DELETED;
         } else {
             if ($i->modified > $i->created) {
                 $change_type = ITEM_MODIFIED;
             } else {
                 $change_type = ITEM_NEW;
             }
         }
         /**
          * build up change-list
          */
         switch ($change_type) {
             case ITEM_NEW:
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     if ($task->prio != PRIO_NORMAL && $task->prio != PRIO_UNDEFINED) {
                         global $g_prio_names;
                         $html_details .= ' / ' . $g_prio_names[$task->prio];
                     }
                     $change = new ChangeLine(array('item' => $task, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => '<span class=new>' . __('new') . ' ' . $task->getLabel() . '</span>', 'txt_what' => __('new') . ' ' . $task->getLabel(), 'type' => ChangeLine::NEW_TASK, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('New file'), 'txt_what' => __('New file'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             case ITEM_MODIFIED:
                 $timestamp_last_change = $date_compare;
                 # make sure we use the last occured change type
                 /**
                  * modified tasks
                  */
                 $type = ChangeLine::UPDATED;
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     $txt_what = $html_what = __('modified');
                     $type = ChangeLine::UPDATED;
                     $html_comment = '';
                     if ($comments = Comment::getAll(array('person' => $i->modified_by, 'task' => $task->id, 'date_min' => $timestamp_last_change, 'order_by' => 'created ASC'))) {
                         $last_comment = $comments[count($comments) - 1];
                         $timestamp_last_change = $last_comment->created;
                         if ($last_comment->name && $last_comment->name != __('New Comment')) {
                             # ignore default title
                             $html_comment = strip_tags($last_comment->name) . ': ';
                         }
                         $html_comment .= strip_tags($last_comment->description);
                         $html_comment = asHtml($html_comment);
                     }
                     ### get changed fields ###
                     $changed_fields_hash = array();
                     $html_functions = false;
                     if ($changed_fields_list = ItemChange::getItemChanges(array('item' => $i->id, 'person' => $i->modified_by, 'date_min' => $date_compare))) {
                         foreach ($changed_fields_list as $cf) {
                             $changed_fields_hash[$cf->field] = $cf;
                         }
                         if (isset($changed_fields_hash['status'])) {
                             $status_old = $changed_fields_hash['status']->value_old;
                             if ($task->status == STATUS_COMPLETED && $task->status > $status_old) {
                                 $txt_what = $html_what = __('completed') . ' ' . $task->getLabel();
                                 $html_functions = $PH->getLink('tasksApproved', __('Approve Task'), array('tsk' => $task->id));
                                 unset($changed_fields_hash['status']);
                             } else {
                                 if ($task->status == STATUS_APPROVED && $task->status > $status_old) {
                                     $txt_what = $html_what = __('approved');
                                     unset($changed_fields_hash['status']);
                                 } else {
                                     if ($task->status == STATUS_CLOSED && $task->status > $status_old) {
                                         $txt_what = $html_what = __('closed');
                                         unset($changed_fields_hash['status']);
                                     } else {
                                         if ($task->status == STATUS_OPEN && $task->status < $status_old) {
                                             $txt_what = $html_what = __('reopened');
                                             unset($changed_fields_hash['status']);
                                         } else {
                                             if ($task->status == STATUS_OPEN) {
                                                 unset($changed_fields_hash['status']);
                                             } else {
                                                 if ($task->status == STATUS_BLOCKED) {
                                                     $txt_what = $html_what = __('is blocked');
                                                     unset($changed_fields_hash['status']);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if (isset($changed_fields_hash['parent_task'])) {
                         $txt_what = $html_what = __('moved');
                         $type = ChangeLine::MOVED;
                         unset($changed_fields_hash['parent_task']);
                     } else {
                         if (count($changed_fields_hash) == 1 && isset($changed_fields_hash['name'])) {
                             $txt_what = $html_what = __('renamed');
                             $type = ChangeLine::RENAMED;
                         } else {
                             if (count($changed_fields_hash) == 1 && isset($changed_fields_hash['description'])) {
                                 $txt_what = $html_what = __('edit wiki');
                                 $type = ChangeLine::EDITED_WIKI;
                             } else {
                                 if (count($changed_fields_hash)) {
                                     # status does not count
                                     $html_details .= ' / ' . __('changed:') . ' ' . implode(', ', array_keys($changed_fields_hash));
                                 } else {
                                     if ($html_comment) {
                                         $txt_what = $html_what = __('commented');
                                         $type = ChangeLine::COMMENTED;
                                     }
                                 }
                             }
                         }
                     }
                     if ($html_comment) {
                         $html_details .= ' / ' . $html_comment;
                     }
                     /**
                      * any recents assignments ?
                      * - to avoid confusion only list assignmets if it was to last action,
                      *
                      */
                     require_once "db/class_taskperson.inc.php";
                     $count_assignments = 0;
                     if ($assignments = TaskPerson::getTaskPeople(array('task' => $task->id, 'project' => $task->project, 'date_min' => $task->modified))) {
                         $t_timestamp = '';
                         foreach ($assignments as $a) {
                             if ($a->person != $task->modified_by && $a->created_by == $task->modified_by && $a->assigntype != ASSIGNTYPE_INITIAL) {
                                 $t_timestamp = $a->created;
                                 $count_assignments++;
                             }
                         }
                         if ($count_assignments && $timestamp_last_change < $t_timestamp) {
                             $type = ChangeLine::ASSIGNED;
                             $txt_what = $html_what = __('assigned');
                             $timestamp_last_change = $t_timestamp;
                         }
                         if ($html_comment) {
                             $html_details .= ' / ' . $html_comment;
                         }
                     }
                     /**
                      * any recents attachments by last editor ?
                      */
                     require_once "db/class_file.inc.php";
                     if ($files = File::getAll(array('parent_item' => $task->id, 'project' => $task->project, 'date_min' => $date_compare, 'created_by' => $task->modified_by))) {
                         $count_attached_files = 0;
                         $html_attached = __("attached") . ": ";
                         $t_timestamp = '';
                         $separator = '';
                         foreach ($files as $f) {
                             if ($task->modified_by == $f->modified_by) {
                                 $t_timestamp = $f->created;
                                 $count_attached_files++;
                                 $html_attached .= $separator . $PH->getLink('fileView', $f->name, array('file' => $f->id));
                                 $separator = ', ';
                             }
                         }
                         if ($count_attached_files) {
                             $type = ChangeLine::ATTACHED_FILE;
                             $txt_what = $html_what = __('attached file to');
                             if ($timestamp_last_change < $t_timestamp) {
                                 $html_details .= ' / ' . $html_attached;
                                 $timestamp_last_change = $t_timestamp;
                             }
                         }
                     }
                     if (count($changed_fields_hash)) {
                         $html_details .= " / " . $PH->getLink('itemViewDiff', NULL, array('item' => $task->id, 'date1' => $date_compare, 'date2' => gmdate("Y-m-d H:i:s")));
                     }
                     if ($html_functions) {
                         $html_details .= " | " . $html_functions;
                     }
                     $change = new ChangeLine(array('person_by' => $i->modified_by, 'timestamp' => $i->modified, 'item_id' => $i->id, 'item' => $task, 'type' => $type, 'txt_what' => $txt_what, 'html_what' => $html_what, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('changed File'), 'txt_what' => __('changed File'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             case ITEM_DELETED:
                 /**
                  * deleted tasks
                  */
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     $html_details .= '|' . $PH->getLink('itemsRestore', __('restore'), array('item' => $task->id));
                     $txt_what = $html_what = __('deleted');
                     $change = new ChangeLine(array('item' => $task, 'person_by' => $i->deleted_by, 'timestamp' => $i->deleted, 'item_id' => $i->id, 'type' => ChangeLine::DELETED, 'txt_what' => $txt_what, 'html_what' => $html_what, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('deleted File'), 'txt_what' => ChangeLine::DELETED, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             default:
                 trigger_error("unknown change-type {$change_type}", E_USER_WARNING);
                 break;
         }
     }
     return $changes;
 }
コード例 #8
0
ファイル: Post.class.php プロジェクト: ringe/RAS
 public function loadComments()
 {
     $conditions = "WHERE post_id = '" . $this->id . "'";
     $this->comments = Comment::getAll($conditions);
 }
コード例 #9
0
 /**
  * getSubComments
  *
  * NOTE: This is NOT recursive!
  */
 public function getSubComments()
 {
     if (!($project = Project::getById($this->project))) {
         return array();
     }
     $comments = Comment::getAll(array('parent_comment' => $this->id));
     return $comments;
 }
コード例 #10
0
ファイル: search.inc.php プロジェクト: Bremaweb/streber-1
 static function getForQuery($search_query, $project = NULL)
 {
     $count_overall = 0;
     $results = array();
     global $PH;
     require_once confGet('DIR_STREBER') . "db/class_company.inc.php";
     $args = array('order_str' => NULL, 'has_id' => NULL, 'search' => $search_query);
     foreach ($companies = Company::getAll($args) as $company) {
         $rate = RATE_TYPE_COMPANY;
         $rate *= SearchResult::RateItem($company);
         $rate *= SearchResult::RateTitle($company, $search_query);
         $results[] = new SearchResult(array('name' => $company->name, 'rating' => $rate, 'type' => __('Company'), 'jump_id' => 'companyView', 'jump_params' => array('company' => $company->id, 'q' => $search_query), 'item' => $company));
     }
     require_once confGet('DIR_STREBER') . "db/class_person.inc.php";
     foreach ($people = Person::getPeople(array('search' => $search_query)) as $person) {
         $rate = RATE_TYPE_PERSON;
         $rate *= SearchResult::RateItem($person);
         $rate *= SearchResult::RateTitle($person, $search_query);
         $results[] = new SearchResult(array('name' => $person->name, 'rating' => $rate, 'type' => __('Person'), 'jump_id' => 'personView', 'jump_params' => array('person' => $person->id, 'q' => $search_query), 'item' => $person));
     }
     require_once confGet('DIR_STREBER') . "db/class_project.inc.php";
     $projects = Project::getAll(array('status_min' => 0, 'status_max' => 10, 'search' => $search_query));
     if ($projects) {
         foreach ($projects as $project) {
             $rate = RATE_TYPE_PROJECT;
             if ($project->status == STATUS_TEMPLATE) {
                 $rate *= RATE_PROJECT_IS_TEMPLATE;
             } else {
                 if ($project->status < STATUS_COMPLETED) {
                     $rate *= RATE_PROJECT_IS_OPEN;
                 } else {
                     $rate *= RATE_PROJECT_IS_CLOSED;
                 }
             }
             if ($diz = SearchResult::getExtract($project, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             ### status ###
             global $g_status_names;
             $status = isset($g_status_names[$project->status]) ? $g_status_names[$project->status] : '';
             if ($project->status > STATUS_COMPLETED) {
                 $rate *= RATE_TASK_STATUS_CLOSED;
             } else {
                 if ($project->status >= STATUS_COMPLETED) {
                     $rate *= RATE_TASK_STATUS_COMPLETED;
                 }
             }
             ### for company ###
             $html_location = '';
             if ($company = Company::getVisibleById($project->company)) {
                 $html_location = __('for') . ' ' . $company->getLink();
             }
             $rate *= SearchResult::RateItem($project);
             $rate *= SearchResult::RateTitle($project, $search_query);
             $results[] = new SearchResult(array('name' => $project->name, 'rating' => $rate, 'item' => $project, 'type' => __('Project'), 'jump_id' => 'projView', 'jump_params' => array('prj' => $project->id, 'q' => $search_query), 'extract' => $diz, 'status' => $status, 'html_location' => $html_location));
         }
     }
     require_once confGet('DIR_STREBER') . "db/class_task.inc.php";
     $order_str = get('sort_' . $PH->cur_page->id . "_tasks");
     $tasks = Task::getAll(array('order_by' => $order_str, 'search' => $search_query, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED));
     if ($tasks) {
         foreach ($tasks as $task) {
             $rate = RATE_TYPE_TASK;
             $rate *= SearchResult::RateItem($task);
             $rate *= SearchResult::RateTitle($task, $search_query);
             if ($task->category == TCATEGORY_FOLDER) {
                 $rate *= RATE_TASK_IS_FOLDER;
             }
             if ($diz = SearchResult::getExtract($task, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             global $g_status_names;
             $status = isset($g_status_names[$task->status]) ? $g_status_names[$task->status] : '';
             if ($task->status > STATUS_COMPLETED) {
                 $rate *= RATE_TASK_STATUS_CLOSED;
             } else {
                 if ($task->status >= STATUS_COMPLETED) {
                     $rate *= RATE_TASK_STATUS_COMPLETED;
                 }
             }
             if ($project = Project::getVisibleById($task->project)) {
                 $prj = $project->getLink();
             } else {
                 $prj = '';
             }
             $html_location = __('in') . " <b>{$prj}</b> &gt; " . $task->getFolderLinks();
             $is_done = $task->status < STATUS_COMPLETED ? false : true;
             $results[] = new SearchResult(array('name' => $task->name, 'rating' => $rate, 'extract' => $diz, 'item' => $task, 'type' => $task->getLabel(), 'status' => $status, 'html_location' => $html_location, 'is_done' => $is_done, 'jump_id' => 'taskView', 'jump_params' => array('tsk' => $task->id, 'q' => $search_query)));
         }
     }
     require_once confGet('DIR_STREBER') . "db/class_comment.inc.php";
     $comments = Comment::getAll(array('search' => $search_query));
     if ($comments) {
         foreach ($comments as $comment) {
             $rate = RATE_TYPE_COMMENT;
             $rate *= SearchResult::RateItem($comment);
             $rate *= SearchResult::RateTitle($comment, $search_query);
             if ($diz = SearchResult::getExtract($comment, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             if ($project = Project::getVisibleById($comment->project)) {
                 $prj = $project->getLink();
             } else {
                 $prj = '';
             }
             $html_location = __('on') . " <b>{$prj}</b>";
             $is_done = false;
             if ($task = Task::getVisibleById($comment->task)) {
                 if ($folders = $task->getFolderLinks()) {
                     $html_location .= ' &gt; ' . $folders;
                 }
                 $html_location .= ' &gt; ' . $task->getLink(false);
                 if ($task->status >= STATUS_COMPLETED) {
                     $is_done = true;
                 }
             } else {
                 $html_location = '';
             }
             $results[] = new SearchResult(array('name' => $comment->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Comment'), 'html_location' => $html_location, 'jump_id' => 'commentView', 'jump_params' => array('comment' => $comment->id, 'q' => $search_query), 'item' => $comment, 'is_done' => $is_done));
         }
     }
     $count_overall += count($comments);
     require_once confGet('DIR_STREBER') . "db/class_effort.inc.php";
     $efforts = Effort::getAll(array('search' => $search_query));
     if ($efforts) {
         foreach ($efforts as $effort) {
             $rate = RATE_TYPE_EFFORT;
             $rate *= SearchResult::RateItem($effort);
             $rate *= SearchResult::RateTitle($effort, $search_query);
             if ($diz = SearchResult::getExtract($effort, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             if ($project = Project::getVisibleById($effort->project)) {
                 $prj = $project->getLink();
             } else {
                 $prj = '';
             }
             $html_location = __('on') . " <b>{$prj}</b>";
             $is_done = false;
             if ($task = Task::getVisibleById($effort->task)) {
                 if ($folders = $task->getFolderLinks()) {
                     $html_location .= ' &gt; ' . $folders;
                 }
                 $html_location .= ' &gt; ' . $task->getLink(false);
                 if ($task->status >= STATUS_COMPLETED) {
                     $is_done = true;
                 }
             } else {
                 $html_location = '';
             }
             $results[] = new SearchResult(array('name' => $effort->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Effort'), 'html_location' => $html_location, 'jump_id' => 'effortView', 'jump_params' => array('effort' => $effort->id, 'q' => $search_query), 'item' => $effort, 'is_done' => $is_done));
         }
     }
     $count_overall += count($efforts);
     return $results;
 }
コード例 #11
0
ファイル: task_move.inc.php プロジェクト: Bremaweb/streber-1
function _moveTask($task_id, $target_project_id, $target_task_id)
{
    $task = Task::getEditableById($task_id);
    if (!$task) {
        new FeedbackWarning(sprintf(__("Can not edit tasks with ID %s"), $task_id));
        return false;
    }
    $target_parents = _getParentOfTaskId($target_task_id);
    if (_isTaskInList($task, $target_parents)) {
        new FeedbackWarning(sprintf(__("Can not move task <b>%s</b> to own child."), $task->name));
        return false;
    }
    $task->parent_task = $target_task_id;
    $task->update();
    ### move task to another project
    if ($target_project_id != $task->project) {
        $task->project = $target_project_id;
        ### move linked comments
        if ($comments = Comment::getAll(array('visible_only' => false, 'alive_only' => false, 'task' => $task->id))) {
            foreach ($comments as $c) {
                $c->project = $target_project_id;
                $c->update();
            }
        }
        ### move linked efforts
        if ($efforts = Effort::getAll(array('visible_only' => false, 'alive_only' => false, 'task' => $task->id))) {
            foreach ($efforts as $e) {
                $e->project = $target_project_id;
                $e->update();
            }
        }
        ### move subtasks
        foreach ($task->getSubtasksRecursiveAll(array('visible_only' => true, 'alive_only' => false)) as $subtask) {
            _moveTask($subtask->id, $target_project_id, $subtask->parent_task);
        }
        ### move linked issue
        if ($task->issue_report) {
            $task->issue_report->project = $target_project_id;
        }
    }
    $task->update();
    $task->nowChangedByUser();
    return true;
}