Example #1
0
 public function __construct(PFUser $user)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $user_name = $hp->purify($user->getRealName());
     $steps = array(new Tuleap_Tour_Step($GLOBALS['Language']->getText('my_tour', 'welcome_title'), $GLOBALS['Language']->getText('my_tour', 'welcome', $user_name)), new Tuleap_Tour_Step($GLOBALS['Language']->getText('my_tour', 'my_personal_page_title'), $GLOBALS['Language']->getText('my_tour', 'my_personal_page'), 'bottom', 'ul.nav > li:first-child'), new Tuleap_Tour_Step($GLOBALS['Language']->getText('my_tour', 'projects_title'), $GLOBALS['Language']->getText('my_tour', 'projects'), 'bottom', 'ul.nav > li.projects-nav'), new Tuleap_Tour_Step($GLOBALS['Language']->getText('my_tour', 'help_title'), $GLOBALS['Language']->getText('my_tour', 'help'), 'bottom', 'ul.nav > li.help-nav'), new Tuleap_Tour_Step($GLOBALS['Language']->getText('my_tour', 'search_title'), $GLOBALS['Language']->getText('my_tour', 'search'), 'bottom', 'ul.nav.pull-right > form'), new Tuleap_Tour_Step($GLOBALS['Language']->getText('my_tour', 'user_menu_title'), $GLOBALS['Language']->getText('my_tour', 'user_menu'), 'bottom', 'ul.nav.pull-right > li.user-menu'), new Tuleap_Tour_Step($GLOBALS['Language']->getText('my_tour', 'end_tour_title'), $GLOBALS['Language']->getText('my_tour', 'end_tour')));
     parent::__construct(self::TOUR_NAME, $steps);
 }
 /**
  * Send mail to project administrators after daliy user sync.
  *
  * @param String  $recipients  List of project administrators emails we want to notify
  * @param String  $projectName Public name of the project we want to notify its administrators
  * @param PFUser  $user        Suspended user after LDAP daily synchro
  * @param String  $subject     The subject of the notification mail
  * @param String  $body        The content of the notification mail
  *
  * @return boolean
  */
 public function notifyProjectsAdmins($recipients, $projectName, $user, $subject, $body)
 {
     $notificationStatus = true;
     try {
         $mail = $this->prepareMail($recipients, $projectName, $subject, $body);
         if (!$mail->send()) {
             $this->logger->error("LDAP daily synchro job has suspended this user " . $user->getRealName() . " (" . $user->getEmail() . ", but failed to notify administrators of <{$projectName}> project :" . $e->getMessage());
             $notificationStatus = false;
         }
     } catch (InvalidArgumentException $e) {
         $this->logger->warn("LDAP daily synchro job has suspended this user " . $user->getRealName() . " (" . $user->getEmail() . ":" . $e->getMessage());
         $notificationStatus = false;
     } catch (Zend_Mail_Exception $e) {
         $this->logger->error("LDAP daily synchro job has suspended this user " . $user->getRealName() . " (" . $user->getEmail() . "), but faced an issue during project administrators notification :" . $e->getMessage());
     }
     return $notificationStatus;
 }
 /**
  *  method to stamp each pdf page (add a banner with timestamp user real name and  confidentiality level)
  *  @param  void
  *  @return void
  */
 public function stamp($values)
 {
     // Prepare stamp
     if ($values != null) {
         $first = true;
         foreach ($values as $value) {
             if ($first) {
                 $sep = '';
                 $first = false;
             } else {
                 $sep = ', ';
             }
             $valueTxt = $sep . $value->getName();
         }
     } else {
         $valueTxt = '';
     }
     $text = "Downloaded on " . date("d M Y H:i", $_SERVER['REQUEST_TIME']) . " by " . $this->user->getRealName() . " " . $valueTxt;
     $stamp = $text . " // " . $text;
     // Text and box style
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     $style->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     $style->setLineColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     //get pdf watermarking level based on number of pages in pdf document.
     $watermarkingLevel = $this->getWatermarkingLevelFromPdfSize();
     // Stamp with adequate watermarking level
     switch ($watermarkingLevel) {
         case self::WATERMARK_EVERYPAGE:
             // Apply it on all pages
             foreach ($this->pdf->pages as $page) {
                 $this->stampOnePage($page, $style, $stamp);
             }
             break;
         case self::WATERMARK_EVERY_TWO_PAGES:
             $count = 0;
             foreach ($this->pdf->pages as $page) {
                 if ($count % 2 == 0) {
                     $this->stampOnePage($page, $style, $stamp);
                 }
                 $count++;
             }
             break;
         case self::WATERMARK_THIRTY_PERCENT_OF_PAGES:
             $pagesToWatermark = $this->getPagesToWatermark(0.3, count($this->pdf->pages));
             foreach ($pagesToWatermark as $pageNo) {
                 $this->stampOnePage($this->pdf->pages[$pageNo], $style, $stamp);
             }
             break;
         case self::WATERMARK_TEN_PERCENT_OF_PAGES:
         default:
             $pagesToWatermark = $this->getPagesToWatermark(0.1, count($this->pdf->pages));
             foreach ($pagesToWatermark as $pageNo) {
                 $this->stampOnePage($this->pdf->pages[$pageNo], $style, $stamp);
             }
             break;
     }
 }
 /**
  * Do all the synchronization between an ldap result and a Tuleap user.
  *
  * This method returns if it modified the user or not. This is usefull during
  * batch process in order to limit computing.
  *
  * @param PFUser       $user User
  * @param LDAPResult $lr   Ldap result
  *
  * @return Boolean True if the method modified the user object
  */
 public function sync(PFUser $user, LDAPResult $lr)
 {
     $modified = false;
     $ldapEmail = $lr->getEmail();
     $realname = ucwords(preg_replace('/^(\\w+).(\\w+)@.*/', '\\1 \\2', $ldapEmail));
     if ($realname !== null && $user->getRealName() != substr($realname, 0, 32)) {
         $user->setRealName($realname);
         $modified = true;
     }
     if ($ldapEmail !== null && $user->getEmail() != $ldapEmail) {
         $user->setEmail($ldapEmail);
         $modified = true;
     }
     return $modified;
 }
 public function user_real_name()
 {
     return $this->user->getRealName();
 }
 private function addUser(array &$recipients, PFUser $user)
 {
     $recipients[] = array('email' => $user->getEmail(), 'real_name' => $user->getRealName());
 }
Example #7
0
 /**
  * Do all the synchronization between an ldap result and a Codendi user.
  *
  * This method returns if it modified the user or not. This is usefull during
  * batch process in order to limit computing.
  *
  * @param PFUser       $user Codendi user
  * @param LDAPResult $lr   Ldap result
  *
  * @return Boolean True if the method modified the user object
  */
 public function sync(PFUser $user, LDAPResult $lr)
 {
     $modified = false;
     if ($lr->getCommonName() !== null && $user->getRealName() != substr($lr->getCommonName(), 0, 32)) {
         $user->setRealName($this->getCommonName($lr));
         $modified = true;
     }
     if ($lr->getEmail() !== null && $user->getEmail() != $lr->getEmail()) {
         $user->setEmail($lr->getEmail());
         $modified = true;
     }
     return $modified;
 }
 /**
  * Prepare the subject of the notification mail
  *
  * @param Integer $projectName Public name of the project we want to notify its administrators
  * @param PFUser  $user        Suspended user after LDAP daily synchro
  *
  * @return String
  */
 private function getSubject($projectName, $user)
 {
     return $GLOBALS['Language']->getText('plugin_ldap', 'ldap_sync_mail_notification_subject', array($user->getRealName(), $projectName));
 }
 public function __construct(PFUser $user)
 {
     $this->user_name = $user->getUserName();
     $this->real_name = $user->getRealName();
     $this->avatar = $user->getAvatarUrl();
 }
 private function fetchFormattedMailUserInfo(PFUser $user)
 {
     $hp = Codendi_HTMLPurifier::instance();
     if ($user && !$user->isAnonymous()) {
         $user_info = '<a href="mailto:' . $hp->purify($user->getEmail()) . '">' . $hp->purify($user->getRealName()) . ' (' . $hp->purify($user->getUserName()) . ')
             </a>';
     } else {
         $user = UserManager::instance()->getUserAnonymous();
         $user->setEmail($this->changeset->getEmail());
         $user_info = $GLOBALS['Language']->getText('tracker_include_artifact', 'anon_user');
     }
     return $user_info;
 }
Example #11
0
 /**
  * Create new account
  *
  * @param PFUser $user
  *
  * @return PFUser
  */
 function createAccount($user)
 {
     $dao = $this->getDao();
     $user_id = $dao->create($user->getUserName(), $user->getEmail(), $user->getPassword(), $user->getRealName(), $user->getRegisterPurpose(), $user->getStatus(), $user->getShell(), $user->getUnixStatus(), $user->getUnixUid(), $user->getUnixBox(), $user->getLdapId(), $_SERVER['REQUEST_TIME'], $user->getConfirmHash(), $user->getMailSiteUpdates(), $user->getMailVA(), $user->getStickyLogin(), $user->getAuthorizedKeys(), $user->getNewMail(), $user->getTimeZone(), $user->getTheme(), $user->getLanguageID(), $user->getExpiryDate(), $_SERVER['REQUEST_TIME']);
     if (!$user_id) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('include_exit', 'error'));
         return 0;
     } else {
         $user->setId($user_id);
         $this->assignNextUnixUid($user);
         $em = $this->_getEventManager();
         $em->processEvent(Event::USER_MANAGER_CREATE_ACCOUNT, array('user' => $user));
         // Create the first layout for the user and add some initial widgets
         $lm = $this->_getWidgetLayoutManager();
         $lm->createDefaultLayoutForUser($user_id);
         switch ($user->getStatus()) {
             case PFUser::STATUS_PENDING:
                 if (ForgeConfig::get('sys_user_approval')) {
                     $this->pending_user_notifier->notifyAdministrator($user);
                 }
                 break;
             case PFUser::STATUS_ACTIVE:
             case PFUser::STATUS_RESTRICTED:
                 $em->processEvent('project_admin_activate_user', array('user_id' => $user_id));
                 break;
         }
         return $user;
     }
 }
 public function welcome_user()
 {
     return $GLOBALS['Language']->getText('account_options', 'welcome') . ' ' . $this->user->getRealName();
 }
 /**
  * Send mail to administrators with the apropriate subject and body   
  * 
  * @param Project $project
  * @param PFUser    $user
  * @param String  $urlData
  * @param String  $hrefApproval
  * @param String  $messageToAdmin
  */
 function sendMail($project, $user, $urlData, $hrefApproval, $messageToAdmin)
 {
     $mail = new Mail();
     //to
     $adminList = $this->extractReceiver($project, $urlData);
     $admins = array_unique($adminList['admins']);
     $to = implode(',', $admins);
     $mail->setTo($to);
     //from
     $from = $user->getEmail();
     $hdrs = 'From: ' . $from . "\n";
     $mail->setFrom($from);
     $mail->setSubject($GLOBALS['Language']->getText($this->getTextBase(), 'mail_subject_' . $this->getType(), array($project->getPublicName(), $user->getRealName())));
     $link = $this->getRedirectLink($urlData, $GLOBALS['Language']);
     $body = $GLOBALS['Language']->getText($this->getTextBase(), 'mail_content_' . $this->getType(), array($user->getRealName(), $user->getName(), $link, $project->getPublicName(), $hrefApproval, $messageToAdmin, $user->getEmail()));
     if ($adminList['status'] == false) {
         $body .= "\n\n" . $GLOBALS['Language']->getText($this->getTextBase(), 'mail_content_unvalid_ugroup', array($project->getPublicName()));
     }
     $mail->setBody($body);
     if (!$mail->send()) {
         exit_error($GLOBALS['Language']->getText('global', 'error'), $GLOBALS['Language']->getText('global', 'mail_failed', array($GLOBALS['sys_email_admin'])));
     }
     $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('include_exit', 'request_sent'), CODENDI_PURIFIER_DISABLED);
     $GLOBALS['Response']->redirect('/my');
     exit;
 }
Example #14
0
 public function getRealName()
 {
     return $this->user->getRealName();
 }