/** * Delete specific project group * * @param void * @return null */ function delete() { if ($this->active_project_group->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_project_group->canDelete($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->request->isSubmitted()) { $delete = $this->active_project_group->delete(); if ($delete && !is_error($delete)) { if ($this->request->getFormat() == FORMAT_HTML) { flash_success("Project group ':name' has been deleted", array('name' => $this->active_project_group->getName())); $this->redirectTo('project_groups'); } else { $this->httpOk(); } // if } else { if ($this->request->getFormat() == FORMAT_HTML) { flash_error("Failed to delete ':name' group. Reason: :reason", array('name' => $this->active_project_group->getName(), 'reason' => $delete->getMessage())); $this->redirectTo('project_groups'); } else { $this->serveData($delete); } // if } // if } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if }
/** * Select project group helper * * Params: * * - value - ID of selected group * - optional - boolean * - can_create_new - Should this select box offer option to create a new * company from within the list * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_project_group($params, &$smarty) { static $ids = array(); $optional = array_var($params, 'optional', true, true); $value = array_var($params, 'value', null, true); $can_create_new = array_var($params, 'can_create_new', true, true); $id = array_var($params, 'id', null, true); if (empty($id)) { $counter = 1; do { $id = "select_project_group_dropdown_{$counter}"; $counter++; } while (in_array($id, $ids)); } // if $ids[] = $id; $params['id'] = $id; $groups = ProjectGroups::findAll($smarty->get_template_vars('logged_user'), true); if ($optional) { $options = array(option_tag(lang('-- None --'), ''), option_tag('', '')); } else { $options = array(); } // if if (is_foreachable($groups)) { foreach ($groups as $group) { $option_attributes = array('class' => 'object_option'); if ($value == $group->getId()) { $option_attributes['selected'] = true; } // if $options[] = option_tag($group->getName(), $group->getId(), $option_attributes); } // foreach } // if if ($can_create_new) { $params['add_object_url'] = assemble_url('project_groups_quick_add'); $params['object_name'] = 'project_group'; $params['add_object_message'] = lang('Please insert new project group name'); $logged_user = get_logged_user(); if (instance_of($logged_user, 'User') && ProjectGroup::canAdd($logged_user)) { $options[] = option_tag('', ''); $options[] = option_tag(lang('New Project Group...'), '', array('class' => 'new_object_option')); } // if } // if return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>'; }
/** * Return number of projects in a specific group * * @param ProjectGroup $group * @return integer */ function countByGroup($group) { return Projects::count(array('group_id = ? AND type = ?', $group->getId(), PROJECT_TYPE_NORMAL)); }
/** * approve - Approve pending project. * * @param object The User object who is doing the updating. * @access public */ function approve(&$user) { if ($this->getStatus() == 'A') { $this->setError(_("Group already active")); return false; } db_begin(); // Step 1: Activate group and create LDAP entries if (!$this->setStatus($user, 'A')) { db_rollback(); return false; } // // // Tracker Integration // // $ats = new ArtifactTypes($this); if (!$ats || !is_object($ats)) { $this->setError(_('Error creating ArtifactTypes object')); db_rollback(); return false; } else { if ($ats->isError()) { $this->setError(sprintf(_('ATS%d: %s'), 1, $ats->getErrorMessage())); db_rollback(); return false; } } if (!$ats->createTrackers()) { $this->setError(sprintf(_('ATS%d: %s'), 2, $ats->getErrorMessage())); db_rollback(); return false; } // // // Forum Integration // // $f = new Forum($this); if (!$f->create('Open-Discussion', 'General Discussion', 1, '', 1, 0)) { $this->setError(sprintf(_('F%d: %s'), 1, $f->getErrorMessage())); db_rollback(); return false; } $f = new Forum($this); if (!$f->create('Help', 'Get Public Help', 1, '', 1, 0)) { $this->setError(sprintf(_('F%d: %s'), 2, $f->getErrorMessage())); db_rollback(); return false; } $f = new Forum($this); if (!$f->create('Developers', 'Project Developer Discussion', 0, '', 1, 0)) { $this->setError(sprintf(_('F%d: %s'), 3, $f->getErrorMessage())); db_rollback(); return false; } // // // Doc Mgr Integration // // $dg = new DocumentGroup($this); if (!$dg->create('Uncategorized Submissions')) { $this->setError(sprintf(_('DG: %s'), $dg->getErrorMessage())); db_rollback(); return false; } // // // FRS integration // // $frs = new FRSPackage($this); if (!$frs->create($this->getUnixName())) { $this->setError(sprintf(_('FRSP: %s'), $frs->getErrorMessage())); db_rollback(); return false; } // // // PM Integration // // $pg = new ProjectGroup($this); if (!$pg->create('To Do', 'Things We Have To Do', 1)) { $this->setError(sprintf(_('PG%d: %s'), 1, $pg->getErrorMessage())); db_rollback(); return false; } $pg = new ProjectGroup($this); if (!$pg->create('Next Release', 'Items For Our Next Release', 1)) { $this->setError(sprintf(_('PG%d: %s'), 2, $pg->getErrorMessage())); db_rollback(); return false; } // // // Set Default Roles // // $role = new Role($this); $todo = array_keys($role->defaults); for ($c = 0; $c < count($todo); $c++) { $role = new Role($this); if (!$role->createDefault($todo[$c])) { $this->setError(sprintf(_('R%d: %s'), $c, $role->getErrorMessage())); db_rollback(); return false; } } $admin_group = db_query("SELECT user_id FROM user_group \n\t\tWHERE group_id=" . $this->getID() . " AND admin_flags='A'"); if (db_numrows($admin_group) > 0) { $idadmin_group = db_result($admin_group, 0, 'user_id'); } else { $idadmin_group = 1; } // // // Create MailingList // // if ($GLOBALS['sys_use_mail']) { $mlist = new MailingList($this); if (!$mlist->create('commits', 'Commits', 1, $idadmin_group)) { $this->setError(sprintf(_('ML: %s'), $mlist->getErrorMessage())); db_rollback(); return false; } } db_commit(); $this->sendApprovalEmail(); $this->addHistory('Approved', 'x'); //plugin webcal //change assistant for webcal $params[0] = $idadmin_group; $params[1] = $this->getID(); plugin_hook('change_cal_permission_default', $params); return true; }
public function __construct(Project $project, $forceDisplay = false) { $image = new Image('images/series/' . $project->getID() . '.jpg'); $image->setClass('projectPicture'); $this->addComponent($image); $this->addComponent(new Title("Informations générales", 2)); if ($project->hasExternalSource()) { $subtitle = new Title("Source : ", 4); $subtitle->addComponent($project->getExternalSource()); $this->addComponent($subtitle); } $array = array(array("Titre Original", $project->getOriginalName()), array("Site officiel", $project->getOfficialWebsite()), array("Année de production", $project->getAiringYear()), array("Studio", $project->getStudio()), array("Auteur", $project->getAuthor()), array("Genre", $project->getGenre()), array("Synopsis", $project->getSynopsis()), array("Coproduction", $project->getCoproduction()), array("Vosta", $project->getVosta())); $infos = new SimpleTextComponent(); $infos->setClass('projectInfos'); foreach ($array as $data) { if ($data[1] !== null) { $text = new SimpleTextComponent("<b>" . $data[0] . "</b> "); $text->addComponent($data[1]); $infos->addLine($text); } } $this->addComponent($infos); if ($project->getComment() !== null) { $this->addComponent("<p></p>"); $this->addComponent(new Title("Commentaire", 2)); $this->addComponent(Format::convertTextToHtml($project->getComment())); } $this->addComponent("<p></p>"); $link = Link::newWindowLink("http://zero.xooit.fr/t471-Liens-morts.htm", "Signaler un lien mort"); $link->setClass('deadLinks'); $this->addComponent($link); $this->addComponent("<p></p>"); $this->addComponent(new Title($project->isDoujin() ? "Chapitres" : "Épisodes", 2)); $releases = Release::getAllReleasesForProject($project->getID()); usort($releases, array('Release', 'idSorter')); $list = new SimpleListComponent(); $list->setClass("releaseList"); foreach ($releases as $release) { $list->addComponent(new ReleaseComponent($release, $forceDisplay)); } $this->addComponent($list); $linkedProjects = Project::getProjectsLinkedTo($project); if (!empty($linkedProjects)) { $this->addComponent("<p></p>"); $this->addComponent(new Title("Voir aussi", 2)); $list = new ProjectList(); foreach ($linkedProjects as $link) { $list->addProject($link); } $list->sortByNames(); $list = new ProjectListComponent($list); $list->useImage(true); $this->addComponent($list); } foreach ($project->getBonuses() as $bonus) { $this->addComponent("<p></p>"); $this->addComponent(new Title("Bonus : " . $bonus->getTitle(), 2)); $this->addComponent($bonus->getContent()); } $groups = ProjectGroup::getGroupsForProject($project); foreach ($groups as $group) { foreach ($group->getBonuses() as $bonus) { $this->addComponent("<p></p>"); $this->addComponent(new Title("Bonus : " . $bonus->getTitle(), 2)); $this->addComponent($bonus->getContent()); } } $this->addComponent("<p></p>"); $url = $project->getDiscussionUrl(); if ($url == null) { $url = new Url("http://zero.xooit.fr/posting.php?mode=reply&t=120"); } $link = Link::newWindowLink($url, new Image("images/interface/avis.png", "Donne ton avis sur le forum !")); $link->setClass('discussionLink'); $this->addComponent($link); }
public static function getGroupsForProject($project) { $groups = array(); foreach (ProjectGroup::getAllGroups() as $group) { if ($group->contains($project)) { $groups[] = $group; } } return $groups; }