function move() { $new_parent_id = $this->request->post('new_parent_id'); $new_parent_type = $this->request->post('new_parent_type'); $new_parent_url = ''; $move_mode = false; if (!empty($new_parent_id) && !empty($new_parent_type)) { $move_mode = true; $parent_obj = $sql_part = null; switch ($new_parent_type) { case 'milestone': $parent_obj = new MileStone($new_parent_id); break; case 'ticket': $parent_obj = new Ticket($new_parent_id); break; case 'page': $parent_obj = new Page($new_parent_id); break; } if ($parent_obj) { $body = $this->active_task->getBody(); $doc = new DOMDocument(); if ($doc->loadHTML($body)) { $anc_tags = $doc->getElementsByTagName('a'); $new_parent_url = ''; foreach ($anc_tags as $anc) { if ($anc->nodeValue == 'View Task in Full') { $href = $anc->getAttribute('href'); $fragment = substr($href, strpos($href, '#')); $anc->setAttribute('href', $parent_obj->getViewUrl() . $fragment); break; } } if (!empty($fragment)) { $body_tag = $doc->getElementsByTagName('body'); $body = $doc->saveXML($body_tag->item(0)->firstChild); $comment_id = str_replace('#comment', '', $fragment); } } $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $query = "update \n\t\t\t\t\t\t\thealingcrystals_project_objects \n\t\t\t\t\t\t set \n\t\t\t\t\t\t\tproject_id='" . $parent_obj->getProjectId() . "', \n\t\t\t\t\t\t\tmilestone_id='" . $parent_obj->getMilestoneId() . "', \n\t\t\t\t\t\t\tparent_id='" . $parent_obj->getId() . "', \n\t\t\t\t\t\t\tparent_type='" . $parent_obj->getType() . "', \n\t\t\t\t\t\t\tbody = '" . mysql_real_escape_string($body) . "' \n\t\t\t\t\t\t where\tid='" . $this->active_task->getId() . "'"; mysql_query($query, $link); if (!empty($comment_id)) { $comment_query = "update \n\t\t\t\t\t\t\thealingcrystals_project_objects \n\t\t\t\t\t\t set \n\t\t\t\t\t\t\tproject_id='" . $parent_obj->getProjectId() . "', \n\t\t\t\t\t\t\tmilestone_id='" . $parent_obj->getMilestoneId() . "', \n\t\t\t\t\t\t\tparent_id='" . $parent_obj->getId() . "', \n\t\t\t\t\t\t\tparent_type='" . $parent_obj->getType() . "', \n\t\t\t\t\t\t\tposition=null\n\t\t\t\t\t\t where\tid='" . $comment_id . "'"; mysql_query($comment_query, $link); } mysql_close($link); $new_parent_url = $parent_obj->getViewUrl() . '#task' . $this->active_task->getId(); $cache_id = TABLE_PREFIX . 'project_objects_id_' . $this->active_task->getId(); $cache_obj = cache_get($cache_id); if ($cache_obj) { cache_remove($cache_id); } } } else { $listing = array(); switch ($this->active_task_parent->getType()) { case 'Milestone': //$listing = Milestones::findByProject($this->active_project, $this->logged_user); $listing = Milestones::findActiveByProject_custom($this->active_project); break; case 'Ticket': $listing = Tickets::findOpenByProjectByNameSort($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()); break; case 'Page': $categories = Categories::findByModuleSection($this->active_project, 'pages', 'pages'); $listing = Pages::findByCategories($categories, STATE_VISIBLE, $this->logged_user->getVisibility()); /*foreach($categories as $category){ $listing = array_merge($listing, Pages::findByCategory($category, STATE_VISIBLE, $this->logged_user->getVisibility())); }*/ break; } $this->smarty->assign(array('teams' => Projects::findNamesByUser($this->logged_user), 'listing' => $listing, 'task_parent_id' => $this->active_task_parent->getId())); } $this->smarty->assign('new_parent_url', $new_parent_url); $this->smarty->assign('move_mode', $move_mode); }
function get_collection() { $parent_id = $this->request->post('parent_id'); $team_obj = new Project($parent_id); $object_type = $this->request->post('object_type'); $listing = array(); switch ($object_type) { case 'milestone': //$listing = Milestones::findByProject($team_obj, $this->logged_user); $listing = Milestones::findActiveByProject_custom($team_obj); break; case 'ticket': $listing = Tickets::findOpenByProjectByNameSort($team_obj, STATE_VISIBLE, $this->logged_user->getVisibility()); break; case 'page': $categories = Categories::findByModuleSection($team_obj, 'pages', 'pages'); $listing = Pages::findByCategories($categories, STATE_VISIBLE, $this->logged_user->getVisibility()); /*foreach($categories as $category){ $listing = array_merge($listing, Pages::findByCategory($category, STATE_VISIBLE, $this->logged_user->getVisibility())); }*/ break; } $this->smarty->assign('options', $listing); }