/** * @return ProjectUGroup[] */ public function getListOfInvolvedStaticUgroups(Tracker $template_tracker) { $project = $template_tracker->getProject(); $ugroups = array(); foreach ($this->permissions_dao->getAuthorizedStaticUgroupIds($template_tracker->getId()) as $id) { $ugroups[] = $this->ugroup_manager->getUGroup($project, $id); } return $ugroups; }
/** * Build an instance of static value * * @return Tracker_FormElement_Field_List_Bind_UgroupsValue */ private function getUgroupsValueInstance($id, Project $project, $ugroup_id, $is_hidden) { $ugroup = $this->ugroup_manager->getUGroup($project, $ugroup_id); if ($ugroup) { return new Tracker_FormElement_Field_List_Bind_UgroupsValue($id, $ugroup, $is_hidden); } }
public function getFieldDataFromRESTObject(array $rest_data, Tracker_FormElement_Field_List $field) { if (isset($rest_data['id'])) { $representation_class = '\\Tuleap\\Project\\REST\\UserGroupRepresentation'; $value = call_user_func_array($representation_class . '::getProjectAndUserGroupFromRESTId', array($rest_data['id'])); $id = $value['user_group_id']; $project_id = $value['project_id']; $bind_value = $this->getValueByUGroupId($id); if ($bind_value) { return Tracker_FormElement_Field_OpenList::BIND_PREFIX . $bind_value->getId(); } if (!$project_id) { throw new Tracker_FormElement_InvalidFieldValueException('Bind Value with ID ' . $id . ' does not exist for field ID ' . $field->getId()); } if (!$bind_value) { $project = $field->getTracker()->getProject(); $user_group = $this->ugroup_manager->getUGroup($project, $id); if (!$user_group) { throw new Tracker_FormElement_InvalidFieldValueException('Bind Value with ID ' . $id . ' does not exist for field ID ' . $field->getId()); } $identifier = $user_group->getName(); } } if (isset($rest_data['short_name'])) { $identifier = (string) $rest_data['short_name']; } else { throw new Tracker_FormElement_InvalidFieldValueException('OpenList static fields values should be passed as an object with at least one of the properties "id" or "short_name"'); } $row = $this->getOpenValueDao()->searchByExactLabel($field->getId(), $identifier)->getRow(); if ($row) { return Tracker_FormElement_Field_OpenList::OPEN_PREFIX . $row['id']; } return Tracker_FormElement_Field_OpenList::NEW_VALUE_PREFIX . $identifier; }
protected function getRESTBindValue(Tracker_FormElement_Field_List_Value $value) { $project = $value->getProject(); $class_ugroup_representation = '\\Tuleap\\Project\\REST\\UserGroupRepresentation'; $ugroup_representation = new $class_ugroup_representation(); $ugroup_representation->build($project->getID(), $this->ugroup_manager->getUGroup($project, $value->getUgroupId())); $class_ugroupvalue_representation = '\\Tuleap\\Tracker\\REST\\FieldListBindUGroupValueRepresentation'; $representation = new $class_ugroupvalue_representation(); $representation->build($value, $ugroup_representation); return $representation; }
function send_new_project_email(Project $project) { $ugroup_manager = new UGroupManager(); $admin_ugroup = $ugroup_manager->getUGroup($project, ProjectUGroup::PROJECT_ADMIN); foreach ($admin_ugroup->getMembers() as $user) { /* @var $user PFUser */ $language = $user->getLanguage(); $subject = $GLOBALS['sys_name'] . ' ' . $language->getText('include_proj_email', 'proj_approve', $project->getUnixName()); $presenter = new MailPresenterFactory(); $renderer = TemplateRendererFactory::build()->getRenderer(ForgeConfig::get('codendi_dir') . '/src/templates/mail/'); $mail = new TuleapRegisterMail($presenter, $renderer, "mail-project-register"); $mail = $mail->getMailProject($subject, $GLOBALS['sys_noreply'], $user->getEmail(), $project); $mail->send(); } return true; }
function send_new_project_email(Project $project) { $ugroup_manager = new UGroupManager(); $admin_ugroup = $ugroup_manager->getUGroup($project, ProjectUGroup::PROJECT_ADMIN); $mail_manager = new MailManager(); $hp = Codendi_HTMLPurifier::instance(); foreach ($admin_ugroup->getMembers() as $user) { /* @var $user PFUser */ $language = $user->getLanguage(); $subject = $GLOBALS['sys_name'] . ' ' . $language->getText('include_proj_email', 'proj_approve', $project->getUnixName()); $message = ''; include $language->getContent('include/new_project_email', null, null, '.php'); $mail = $mail_manager->getMailByType('html'); $mail->getLookAndFeelTemplate()->set('title', $hp->purify($subject, CODENDI_PURIFIER_CONVERT_HTML)); $mail->setTo($user->getEmail()); $mail->setSubject($subject); $mail->setBodyHtml($message); $mail->send(); } return true; }