public function __construct(Partner $partner, $content = null) { parent::__construct($partner->getWebsiteUrl(), $content); $this->partner = $partner; if ($content == null) { $this->setContent($partner->getName()); } $this->openNewWindow(true); }
/** * Method used to get the list of users available in the system. * * @param boolean $show_customers Whether to return customers or not * @return array The list of users */ public static function getList($show_customers, $show_inactive) { // FIXME: what about other statuses like "pending"? $stmt = 'SELECT * FROM {{%user}} WHERE usr_id != ?'; $params = array(APP_SYSTEM_USER_ID); if (!$show_inactive) { $stmt .= ' AND usr_status != ?'; $params[] = 'inactive'; } $stmt .= ' ORDER BY usr_status ASC, usr_full_name ASC'; try { $res = DB_Helper::getInstance()->getAll($stmt, $params); } catch (DbException $e) { return ''; } $data = array(); foreach ($res as &$row) { $roles = Project::getAssocList($row['usr_id'], false, true); $role = current($roles); $role = $role['pru_role']; if ($show_customers == false && (@$roles[Auth::getCurrentProject()]['pru_role'] == self::getRoleID('Customer') || count($roles) == 1 && $role == self::getRoleID('Customer'))) { continue; } $row['roles'] = $roles; if (!empty($row['usr_grp_id'])) { $row['group_name'] = Group::getName($row['usr_grp_id']); } if (!empty($row['usr_par_code'])) { $row['partner_name'] = Partner::getName($row['usr_par_code']); } // add email aliases $row['aliases'] = User::getAliases($row['usr_id']); $data[] = $row; } return $data; }
public function testGetName() { $this->assertEquals(self::STATUS_EXPECTED, $this->partnerStatus->getName()); }
function actionSavePartner($currentUser) { $backUrl = $this->context->getFlowScopeAttr("backUrl"); $partnerID = $this->context->getRequestAttr("id"); $partner = new Partner(); $partnerErrs = array(); $partner->setId($this->context->getRequestAttr("id")); $partner->setPid($this->context->getRequestAttr("projectID")); $partner->setName($this->context->getRequestAttr("name")); if (!is_null($partner->getName())) { $partner->setName(trim($partner->getName())); if (strlen($partner->getName()) < 1) { $partner->setName(null); } } if (is_null($partner->getName())) { $partnerErrs["name"] = "field.error.empty"; } $partner->setEmail($this->context->getRequestAttr("email")); if (!is_null($partner->getEmail())) { $partner->setEmail(trim($partner->getEmail())); if (strlen($partner->getEmail()) < 1) { $partner->setEmail(null); } } if (is_null($partner->getEmail())) { $partnerErrs["email"] = "field.error.empty"; } $partner->setTelephone($this->context->getRequestAttr("telephone")); if (!is_null($partner->getTelephone())) { $partner->setTelephone(trim($partner->getTelephone())); if (strlen($partner->getTelephone()) < 1) { $partner->setTelephone(null); } } if (is_null($partner->getTelephone())) { $partnerErrs["telephone"] = "field.error.empty"; } $create = $this->context->getRequestAttr("create"); $partner->setCan_create($create == "1" ? true : false); $timeZone = new DateTimeZone("Europe/Vilnius"); $time = new DateTime("now", $timeZone); $partner->setR_date($time->format("Y-m-d H:i:s")); $partner->setR_user($currentUser->getId()); $this->context->setFlashScopeAttr("partner", $partner); $this->context->setFlashScopeAttr("partnerErrs", $partnerErrs); if (!is_null($partner->getId())) { $oldPartner = $this->partnerDao->get($partner->getId()); if (is_null($oldPartner) || is_string($oldPartner)) { $this->context->setRequestScopeAttr("error", "partner.error.notfound"); $this->cancelPartnerEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } } $projectID = $partner->getPid(); if (is_null($projectID)) { $this->context->setRequestScopeAttr("error", "project.error.notfound"); $this->cancelPartnerEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } $project = $this->projectDao->get($projectID); if (is_null($project)) { $this->context->setRequestScopeAttr("error", "project.error.notfound"); $this->cancelPartnerEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } else { if (is_string($project)) { $this->context->setRequestScopeAttr("error", "error.dberror"); $this->context->setRequestScopeAttr("errortxt", $project); $project = null; $this->cancelPartnerEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } } $this->context->setFlashScopeAttr("partnerProject", $project); if (count($partnerErrs) >= 1) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } if (!is_null($partner->getId())) { if ($oldPartner->getEmail() != $partner->getEmail()) { $project->setCruid($this->generateCode()); $store = $this->storeProject($project); if (!$store) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return TRUE; } return FALSE; } } } $this->sendNewProjectUrl($partner, $project); $store = $this->storePartner($partner); if (!$store) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } $this->cancelPartnerEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; }