/** * Return verbose project filter data * * @param void * @return string */ function getVerboseProjectFilterData() { if ($this->verbose_project_filter_data === false) { if ($this->getProjectFilter() == PROJECT_FILTER_SELECTED) { $project_ids = $this->getProjectFilterData(); $rows = db_execute_all('SELECT DISTINCT id, name FROM ' . TABLE_PREFIX . 'projects WHERE id IN (?)', $project_ids); if (is_foreachable($rows)) { $names = array(); foreach ($rows as $row) { $names[] = $row['name']; } // foreach require_once SMARTY_PATH . '/plugins/function.join.php'; $this->verbose_project_filter_data = smarty_function_join(array('items' => $names)); } // if } // if if (empty($this->verbose_project_filter_data)) { $this->verbose_project_filter_data = null; } // if } // if return $this->verbose_project_filter_data; }
/** * Returns list of system roles which have can_see_private_objects set to Yes * * If $as_string is set to yes function returns list of names separated with * comma (like Adminstrator, Project Manager, People Manager or Member) * * @param boolean $as_string * @return array */ function who_can_see_private_objects($as_string = false, $separator = null) { $roles = Roles::findSystemRoles(); $result = array(); if (is_foreachable($roles)) { foreach ($roles as $role) { if ($role->getPermissionValue('admin_access') || $role->getPermissionValue('project_management') || $role->getPermissionValue('can_see_private_objects')) { $result[] = $as_string ? $role->getName() : $role; } // if } // foreach } // if if ($as_string) { if ($separator === null) { $separator = lang(' and '); } // if require_once SMARTY_PATH . '/plugins/function.join.php'; return smarty_function_join(array('items' => $result, 'final_separator' => $separator), $smarty); } else { return $result; } // if }
/** * Add people to the project * * @param void * @return null */ function add_people() { if (!$this->active_project->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $project_users = $this->active_project->getUsers(); if (is_foreachable($project_users)) { $exclude_users = objects_array_extract($project_users, 'getId'); } else { $exclude_users = null; } // if $this->smarty->assign(array('exclude_users' => $exclude_users)); if ($this->request->isSubmitted()) { $user_ids = $this->request->post('users'); if (!is_foreachable($user_ids)) { flash_error('No users selected'); $this->redirectToUrl($this->active_project->getViewUrl()); } // if $users = Users::findByIds($user_ids); $project_permissions = $this->request->post('project_permissions'); $role = null; $role_id = (int) array_var($project_permissions, 'role_id'); if ($role_id) { $role = Roles::findById($role_id); } // if if (instance_of($role, 'Role') && $role->getType() == ROLE_TYPE_PROJECT) { $permissions = null; } else { $permissions = array_var($project_permissions, 'permissions'); if (!is_array($permissions)) { $permissions = null; } // if } // if if (is_foreachable($users)) { db_begin_work(); $added = array(); foreach ($users as $user) { $add = $this->active_project->addUser($user, $role, $permissions); if ($add && !is_error($add)) { $added[] = $user->getDisplayName(); } else { db_rollback(); flash_error('Failed to add ":user" to ":project" project', array('user' => $user->getDisplayName(), 'project' => $this->active_project->getName())); $this->redirectToUrl($this->active_project->getAddPeopleUrl()); } // if } // foreach db_commit(); if ($this->request->isApiCall()) { $this->httpOk(); } else { require_once SMARTY_PATH . '/plugins/function.join.php'; flash_success(':users added to :project project', array('users' => smarty_function_join(array('items' => $added)), 'project' => $this->active_project->getName())); $this->redirectToUrl($this->active_project->getPeopleUrl()); } // if } // if } else { if ($this->request->isApiCall()) { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if } // if }