private function workspace_toxml(Project $ws, $activeProjects) { $parentIds = ''; $i = 1; $pid = $ws->getPID($i); while ($pid != $ws->getId() && $pid != 0 && $i <= 10) { $coma = $parentIds == '' ? '' : ','; if (in_array($pid, $activeProjects)) { $parentIds .= $coma . $pid; } $i++; $pid = $ws->getPID($i); } $this->instance->startElement('workspace'); $this->instance->startElement('id'); $this->instance->text($ws->getId()); $this->instance->endElement(); $this->instance->startElement('name'); $this->instance->text($ws->getName()); $this->instance->endElement(); $this->instance->startElement('description'); $this->instance->text($ws->getDescription()); $this->instance->endElement(); $this->instance->startElement('parentids'); $this->instance->text($parentIds); $this->instance->endElement(); $this->instance->endElement(); }
/** * Renders the chart * @param IUser $logged_user * @return string */ function render(IUser $logged_user) { $db_result = DB::execute("SELECT milestone_id, COUNT(*) as count FROM " . TABLE_PREFIX . "project_objects WHERE project_id = ? AND type='Task' AND state >= ? AND visibility >= ? GROUP BY milestone_id", $this->project->getId(), STATE_VISIBLE, $logged_user->getMinVisibility()); $array_result = $db_result instanceof DBResult ? $db_result->toArrayIndexedBy('milestone_id') : false; if (is_foreachable($array_result)) { $pie_chart = new PieChart('400px', '400px', 'milestone_eta_report_pie_chart_placeholder'); $this->serie_array = array(); $this->milestones = array(); // Set data for the rest foreach ($array_result as $serie_data) { $point = new ChartPoint('1', $serie_data['count']); $serie = new ChartSerie($point); if (intval($serie_data['milestone_id'])) { $milestone = new RemediaMilestone(intval($serie_data['milestone_id'])); $label = PieChart::makeShortForPieChart($milestone->getName()); $this->milestones[] = $milestone; } else { $label = lang('No Milestone'); } //if $serie->setOption('label', $label); $this->serie_array[] = $serie; } //foreach $pie_chart->addSeries($this->serie_array); return $pie_chart->render(); } else { return '<p class="empty_slate">' . lang('There are no milestones in this project.') . '</p>'; } //if }
private function getAlreadyExistingTracker() { foreach ($this->reserved_names as $itemname) { if ($this->tracker_factory->isShortNameExists($itemname, $this->project->getId())) { return $itemname; } } }
/** * Prepare search conditions string based on input params * * @param string $search_for Search string * @param Project $project Search in this project * @return array */ function getSearchConditions($search_for, Project $project, $include_private = false) { if ($include_private) { return DB::prepareString('MATCH (`content`) AGAINST (? IN BOOLEAN MODE) AND `project_id` = ?', array($search_for, $project->getId())); } else { return DB::prepareString('MATCH (`content`) AGAINST (? IN BOOLEAN MODE) AND `project_id` = ? AND `is_private` = ?', array($search_for, $project->getId(), false)); } // if }
/** * Check if this user is part of specific project * * @param Project $project * @return boolean */ function isProjectUser(Project $project) { if (!isset($this->is_project_user_cache[$project->getId()])) { $project_user = ProjectUsers::findById(array('project_id' => $project->getId(), 'user_id' => $this->getId())); // findById $this->is_project_user_cache[$project->getId()] = $project_user instanceof ProjectUser; } // if return $this->is_project_user_cache[$project->getId()]; }
/** * Return project messages that are marked as important for specific project * * @param Project $project * @param boolean $include_private Include private messages * @return array */ static function getImportantProjectMessages(Project $project, $include_private = false) { if ($include_private) { $conditions = array('`project_id` = ? AND `is_important` = ?', $project->getId(), true); } else { $conditions = array('`project_id` = ? AND `is_important` = ? AND `is_private` = ?', $project->getId(), true, false); } // if return self::findAll(array('conditions' => $conditions, 'order' => '`created_on` DESC')); // findAll }
/** * Return closed tickets for specific project * * @param Project $project * @param boolean $include_private Include private tickets * @return array */ static function getClosedProjectTickets(Project $project, $include_private = false) { if ($include_private) { $conditions = array('`project_id` = ? AND `closed_on` > ?', $project->getId(), EMPTY_DATETIME); } else { $conditions = array('`project_id` = ? AND `closed_on` > ? AND `is_private` = ?', $project->getId(), EMPTY_DATETIME, false); } // if return self::findAll(array('conditions' => $conditions, 'order' => '`created_on` DESC')); // findAll }
/** * * @param SimpleXMLElement $root * Export in XML the list of tracker with a cardwall */ public function export(SimpleXMLElement $root) { $cardwall_node = $root->addChild(CardwallConfigXml::NODE_CARDWALL); $trackers_node = $cardwall_node->addChild(CardwallConfigXml::NODE_TRACKERS); $trackers = $this->tracker_factory->getTrackersByGroupId($this->project->getId()); foreach ($trackers as $tracker) { $this->addTrackerChild($tracker, $trackers_node); } $rng_path = realpath(CARDWALL_BASE_DIR . '/../www/resources/xml_project_cardwall.rng'); $this->xml_validator->validate($cardwall_node, $rng_path); }
public function toJSON() { $json = array(); $json['fields'] = array(); $json['fields']['project'] = array("id" => $this->project->getId()); $json['fields']['summary'] = $this->summary; $json['fields']['issuetype'] = array("id" => $this->issueType->getId()); $json['fields']['assignee'] = array("name" => $this->assignee->getName()); $json['fields']['reporter'] = array("name" => $this->reporter->getName()); $json['fields']['labels'] = $this->labels; $json['fields']['description'] = $this->description; return $json; }
protected function adminGitAdminsView($is_admin_mass_change_allowed) { $params = $this->getData(); $presenter = new GitPresenters_AdminGitAdminsPresenter($this->groupId, $is_admin_mass_change_allowed, $this->ugroup_manager->getStaticUGroups($this->project), $this->git_permissions_manager->getCurrentGitAdminUgroups($this->project->getId())); $renderer = TemplateRendererFactory::build()->getRenderer(dirname(GIT_BASE_DIR) . '/templates'); echo $renderer->renderToString('admin', $presenter); }
public function addUserAsProjectAdmin(Project $project, PFUser $user) { $project_id = $this->da->escapeInt($project->getId()); $user_id = $this->da->escapeInt($user->getId()); $sql = "UPDATE user_group\n SET admin_flags = 'A'\n WHERE group_id = {$project_id}\n AND user_id = {$user_id}"; return $this->update($sql); }
/** * * @param SmartyHelper $smartyHelper * @param Command $prj * @param int $userid */ public static function dashboardSettings(SmartyHelper $smartyHelper, Project $prj, $userid, $teamid) { $pluginDataProvider = PluginDataProvider::getInstance(); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_ISSUE_SELECTION, $prj->getIssueSelection()); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $teamid); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $userid); $team = TeamCache::getInstance()->getTeam($teamid); $startT = $team->getDate(); $now = time(); $endT = mktime(23, 59, 59, date('m', $now), date('d', $now), date('Y', $now)); if ($startT > $endT) { $startT = strtotime('today midnight'); } //echo "start $startT end $endT<br>"; // Calculate a nice day interval $nbWeeks = ($endT - $startT) / 60 / 60 / 24; $interval = ceil($nbWeeks / 20); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startT); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endT); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_INTERVAL, $interval); // save the DataProvider for Ajax calls $_SESSION[PluginDataProviderInterface::SESSION_ID] = serialize($pluginDataProvider); // create the Dashboard $dashboard = new Dashboard('Project' . $prj->getId()); $dashboard->setDomain(IndicatorPluginInterface::DOMAIN_PROJECT); $dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK)); $dashboard->setTeamid($teamid); $dashboard->setUserid($userid); $data = $dashboard->getSmartyVariables($smartyHelper); foreach ($data as $smartyKey => $smartyVariable) { $smartyHelper->assign($smartyKey, $smartyVariable); } }
public function getMatchingArtifacts(PFUser $user, Project $project, array $tracker_ids, Tracker_Hierarchy $hierarchy, Tracker_CrossSearch_Query $query, $excluded_artifact_ids = array()) { $shared_fields = $this->shared_field_factory->getSharedFields($query->getSharedFields()); $semantic_fields = $query->getSemanticCriteria(); $artifacts_info = $this->dao->searchMatchingArtifacts($user, $project->getId(), $query, $tracker_ids, $shared_fields, $semantic_fields, $this->artifact_link_field_ids_for_column_display, $excluded_artifact_ids); return $this->result_sorter->buildTreeWithMissingChildren($user, $artifacts_info, $excluded_artifact_ids); }
/** * Handle on_project_user_removed event * * @param Project $project * @param User $user * @return null */ function resources_handle_on_project_user_removed($project, $user) { $rows = db_execute('SELECT id FROM ' . TABLE_PREFIX . 'project_objects WHERE project_id = ?', $project->getId()); if (is_foreachable($rows)) { $object_ids = array(); foreach ($rows as $row) { $object_ids[] = (int) $row['id']; } // foreach $user_id = $user->getId(); // Assignments cleanup db_execute('DELETE FROM ' . TABLE_PREFIX . 'assignments WHERE user_id = ? AND object_id IN (?)', $user_id, $object_ids); cache_remove('object_starred_by_' . $user_id); cache_remove('object_assignments_*'); cache_remove('object_assignments_*_rendered'); // Starred objects cleanup db_execute('DELETE FROM ' . TABLE_PREFIX . 'starred_objects WHERE user_id = ? AND object_id IN (?)', $user_id, $object_ids); cache_remove('object_starred_by_' . $user_id); // Subscriptions cleanup db_execute('DELETE FROM ' . TABLE_PREFIX . 'subscriptions WHERE user_id = ? AND parent_id IN (?)', $user_id, $object_ids); cache_remove('user_subscriptions_' . $user_id); // remove pinned project PinnedProjects::unpinProject($project, $user); } // if }
/** * Return array of all pages for project * * @param Project * @return ProjectLinks */ static function getAllProjectPages(Project $project) { trace(__FILE__, 'getAllProjectPages():begin'); $conditions = array('`project_id` = ?', $project->getId()); return self::findAll(array('conditions' => $conditions, 'order' => '`id` ASC')); // findAll trace(__FILE__, 'getAllProjectPages():end'); }
/** * Handle on prepare project overview event * * @param NamedList $tabs * @param User $logged_user * @param Project $project * @return null */ function files_handle_on_project_tabs(&$tabs, &$logged_user, &$project) { $tabs->add('attachments', array('text' => lang('Attachments'), 'url' => assemble_url('attachments_list', array('project_id' => $project->getId())))); if ($logged_user->getProjectPermission('file', $project) >= PROJECT_PERMISSION_ACCESS) { $tabs->add('files', array('text' => lang('Files'), 'url' => files_module_url($project))); } // if }
/** * Return charts that belong to specific project * * @param Project $project * @return array */ static function getProjectCharts($project) { $conditions = array(self::getWorkspaceString(), $project->getId()); return self::findAll(array( 'conditions' => $conditions, 'order' => '`created_on` DESC', )); // findAll } // getProjectCharts
public function getId() { if ($this->__isInitialized__ === false) { return (int) $this->_identifier["id"]; } $this->__load(); return parent::getId(); }
public function __construct(PFUser $current_user, Project $project, $milestone_id) { $this->user_id = $current_user->getId(); $this->lang = $this->getLanguageAbbreviation($current_user); $this->project_id = $project->getId(); $this->milestone_id = $milestone_id; $this->view_mode = $current_user->getPreference('agiledashboard_planning_item_view_mode_' . $this->project_id); }
/** * 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; }
/** * Return upload files URL * * @param Project $project * @param Category $category * @return string */ function files_module_upload_url($project, $additional_params = null) { $params = array('project_id' => $project->getId()); if (is_array($additional_params)) { $params = array_merge($params, $additional_params); } // if return assemble_url('project_files_upload', $params); }
/** * Return add ticket URL * * @param Project $project * @param array $additional_params * @return string */ function tickets_module_add_ticket_url($project, $additional_params = null) { $params = array('project_id' => $project->getId()); if ($additional_params !== null) { $params = array_merge($params, $additional_params); } // if return assemble_url('project_tickets_add', $params); }
/** * Find all tasks in project, and prepare them for objects list * * @param Project $project * @param User $user * @param int $state * @return array */ static function findForObjectsList(Project $project, User $user, $state = STATE_VISIBLE) { $result = array(); $today = strtotime(date('Y-m-d')); $tasks = DB::execute("SELECT o.id, o.name,\r\n\t\t\t\t\t\to.category_id,\r\n\t\t\t\t\t\to.milestone_id,\r\n\t\t\t\t\t\to.completed_on,\r\n\t\t\t\t\t\to.integer_field_1 as task_id,\r\n\t\t\t\t\t\to.label_id,\r\n\t\t\t\t\t\to.assignee_id,\r\n\t\t\t\t\t\to.priority,\r\n\t\t\t\t\t\to.delegated_by_id,\r\n\t\t\t\t\t\to.state,\r\n\t\t\t\t\t\to.visibility,\r\n\t\t\t\t\t\to.created_on,\r\n\t\t\t\t\t\to.updated_on,\r\n\t\t\t\t\t\to.due_on,\r\n\t\t\t\t\t\trec.tracked_time\r\n\t\t\t\t\tFROM " . TABLE_PREFIX . "project_objects o \r\n\t\t\t\t\tLEFT JOIN (SELECT parent_id, sum(value) tracked_time FROM " . TABLE_PREFIX . "time_records WHERE state = ? GROUP BY(parent_id)) rec ON(o.id=rec.parent_id)\r\n\t\t\t\t\tWHERE o.type = 'Task' AND o.project_id = ? AND o.state = ? AND o.visibility >= ? ORDER BY o.id DESC", $state, $project->getId(), $state, $user->getMinVisibility()); if (is_foreachable($tasks)) { $task_url = Router::assemble('project_task', array('project_slug' => $project->getSlug(), 'task_id' => '--TASKID--')); $project_id = $project->getId(); $labels = Labels::getIdDetailsMap('AssignmentLabel'); foreach ($tasks as $task) { list($total_subtasks, $open_subtasks) = ProjectProgress::getObjectProgress(array('project_id' => $project_id, 'object_type' => 'Task', 'object_id' => $task['id'])); $taskObj = new Task($task['id']); $result[] = array('id' => $task['id'], 'name' => $task['name'], 'project_id' => $project_id, 'category_id' => $task['category_id'], 'milestone_id' => $task['milestone_id'], 'task_id' => $task['task_id'], 'is_completed' => $task['completed_on'] ? 1 : 0, 'permalink' => str_replace('--TASKID--', $task['task_id'], $task_url), 'label_id' => $task['label_id'], 'label' => $task['label_id'] ? $labels[$task['label_id']] : null, 'assignee_id' => $task['assignee_id'], 'priority' => $task['priority'], 'delegated_by_id' => $task['delegated_by_id'], 'total_subtasks' => $total_subtasks, 'open_subtasks' => $open_subtasks, 'estimated_time' => $taskObj->tracking()->canAdd($user) && $taskObj->tracking()->getEstimate() ? $taskObj->tracking()->getEstimate()->getValue() : 0, 'tracked_time' => $taskObj->tracking()->canAdd($user) ? $task['tracked_time'] : 0, 'is_favorite' => Favorites::isFavorite(array('Task', $task['id']), $user), 'is_archived' => $task['state'] == STATE_ARCHIVED ? 1 : 0, 'visibility' => $task['visibility'], 'created_on' => $task['created_on'] ? $task['created_on'] : $task['updated_on'], 'updated_on' => $task['updated_on'], 'has_attachments' => $taskObj->attachments()->has() ? true : false, 'due_on' => $task['due_on'] ? $task['due_on'] : lang('No due date set')); } // foreach } // if return $result; }
/** * @return Tracker[] */ public function getTrackersUsedAsKanban(Project $project) { $trackers = array(); foreach ($this->dao->getKanbansForProject($project->getId()) as $row) { $tracker = $this->tracker_factory->getTrackerById($row['tracker_id']); if ($tracker) { $trackers[] = $tracker; } } return $trackers; }
public function __construct(PFUser $current_user, Project $project, $milestone_id, $milestone_representation, $paginated_backlog_items_representations, $paginated_milestones_representations) { $this->user_id = $current_user->getId(); $this->lang = $this->getLanguageAbbreviation($current_user); $this->project_id = $project->getId(); $this->milestone_id = $milestone_id; $this->view_mode = $current_user->getPreference('agiledashboard_planning_item_view_mode_' . $this->project_id); $this->milestone_representation = json_encode($milestone_representation); $this->paginated_backlog_items_representations = json_encode($paginated_backlog_items_representations); $this->paginated_milestones_representations = json_encode($paginated_milestones_representations); }
private function filterWikiPagePermissionsAccordingToService(Project $project, array $wiki_page_ugroup_ids) { $wiki_service_ugroup_ids = $this->getWikiServicePermissions($project->getId()); foreach ($wiki_service_ugroup_ids as $wiki_service_ugroup_id) { $this->checkServiceOverridesPagePermission($wiki_page_ugroup_ids, $wiki_service_ugroup_id); } if (empty($wiki_page_ugroup_ids)) { $wiki_page_ugroup_ids = $wiki_service_ugroup_ids; } return array_merge($wiki_page_ugroup_ids, $this->getWikiAdminsGroups()); }
/** * Return all attachments of a certain type for a specific project * * @param array * @param Project $project * @return array */ function getAttachmentsByTypeAndProject($types, Project $project) { if (!$project instanceof Project) { return null; } // if if (!is_array($types)) { $types = array($types); } // if return self::findAll(array('conditions' => array('`rel_object_manager` IN (?) AND `project_id` = ?', $types, $project->getId()), 'order' => '`order` ASC')); }
/** * Add sidebars to project overview page * * @param array $sidebars * @param Project $project * @param User $user */ function frosso_estimated_cost_handle_on_project_overview_sidebars(&$sidebars, Project &$project, User &$user) { if (($user->canUseReports() || $project->isLeader($user)) && $project->canEdit($user)) { $arguments = array('conditions' => array('project_id = ? AND type = ? AND state >= ? AND visibility >= ? AND completed_on IS NULL', $project->getId(), 'Milestone', STATE_VISIBLE, VISIBILITY_NORMAL)); $milestones = DataManager::find($arguments, TABLE_PREFIX . 'project_objects', DataManager::CLASS_NAME_FROM_TABLE, 'RemediaMilestone'); if (is_foreachable($milestones)) { $result = array(); $view = SmartyForAngie::getInstance()->createTemplate(AngieApplication::getViewPath('eta_project_sidebar', 'sidebar', FROSSO_EC_MODULE, AngieApplication::INTERFACE_DEFAULT)); $view->assign(array('milestones' => $milestones, 'logged_user' => $user)); $sidebars[] = array('label' => lang('ETA for this project'), 'is_important' => false, 'id' => 'project_milestones_complete', 'body' => $view->fetch()); } } }
function eventAddFeed($coworkerid, $projectid) { $do_project = new Project(); $do_project->getId($projectid); $this->project_name = $do_project->getProjectName(); $user = array($coworkerid); $this->iduser = $_SESSION["do_User"]->iduser; $do_user = new User(); $do_user->getId($this->iduser); $this->user_full_name = $do_user->getFullName(); $this->idcontact = $coworkerid; $this->idproject = $projectid; $this->addFeed($user); }
public function executeUpdate() { $jira = new sfJiraPlugin($this->getUser()->getProfile()->getJiraLogin(), $this->getUser()->getProfile()->getJiraPassword()); $aProjects = $jira->getProjects(); foreach ($aProjects as $project) { #var_dump( $project ); $c = new Criteria(); $c->add(ProjectPeer::USER_ID, $this->getUser()->getProfile()->getId()); $c->add(ProjectPeer::KEY, $project->key); $p = ProjectPeer::doSelectOne($c); $c = new Criteria(); $c->add(UserPeer::JIRA_LOGIN, $project->lead); $u = UserPeer::doSelectOne($c); if (empty($p)) { $p = new Project(); $p->setKey($project->key); $p->setLeadId(!empty($u) ? $u->getId() : null); $p->setUserId($this->getUser()->getProfile()->getId()); $p->setName($project->name); $p->setUpdated(date('r')); $p->save(); } $issues = $jira->getIssuesForProject($p->getKey()); foreach ($issues as $issue) { #die($p->getKey()); if ($issue->assignee == $this->getUser()->getProfile()->getJiraLogin()) { $c = new Criteria(); $c->add(TaskPeer::KEY, $issue->key); $t = TaskPeer::doSelectOne($c); if (empty($t)) { $c = new Criteria(); $c->add(UserPeer::JIRA_LOGIN, $issue->reporter); $u = UserPeer::doSelectOne($c); $t = new Task(); $t->setProjectId($p->getId()); $t->setTitle($issue->summary); $t->setDescription($issue->description); $t->setKey($issue->key); $t->setUpdated(date('r')); $t->setStatusId($issue->status); $t->setPriorityId($issue->priority); $t->setLeadId(!empty($u) ? $u->getId() : null); $t->save(); } } } } $this->redirect('@homepage'); return sfView::NONE; }