Exemple #1
0
 /**
  * Update the user with the form data.
  *
  * @param Object_User $user
  * @return boolean
  */
 public function updateUser($user)
 {
     if (!is_a($user, 'Object_User')) {
         return false;
     }
     // Check email duplication
     if (Repo_User::getInstance()->emailExists($this->getValue('email'), $user->id)) {
         $this->getElement('email')->addError('Email exists: ' . $this->getValue('email'));
         return false;
     } else {
         $user->email = $this->getValue('email');
     }
     $newPassword = $this->getValue('password');
     if (!empty($newPassword)) {
         $user->password = Auth_Wrapper_User::getPasswordHash($this->getValue('password'));
     }
     $roleIds = $this->getValue('role');
     $user->firstname = $this->getValue('firstname');
     $user->surname = $this->getValue('surname');
     $user->UDID = $this->getValue('UDID');
     if (is_array($roleIds)) {
         $roleIds = implode(',', $roleIds);
     }
     $user->role_id = $roleIds;
     $user->client_id = $this->getValue('client');
     return $user->save();
 }
Exemple #2
0
 /**
  * Returns an instance.
  *
  * Singleton pattern implementation.
  *
  * @return Repo_User
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemple #3
0
 /**
  * The construct function. Must providing the id.
  *
  * @param integer $id
  * @return Object_User
  */
 public function __construct($id)
 {
     $this->_repo = Repo_User::getInstance();
     $this->_dataRow = $this->_repo->findRow($id);
     if ($this->_dataRow) {
         $this->_data = $this->_dataRow->toArray();
         $this->_id = $id;
     }
 }
 /**
  * List client users.
  *
  */
 public function userAction()
 {
     $clientId = $this->_request->getParam('client');
     if ($clientId > 0) {
         $client = new Object_Client($clientId);
         $this->view->clientName = $client->name;
     }
     // js for list sort and search
     $this->view->headScript()->prependFile('/js/libraries/list/list.min.js');
     //js for bootstrap style pagination
     $this->view->headScript()->prependFile('/js/libraries/list/list.pagination.min.js');
     $this->view->users = Repo_User::getInstance()->getClientUsers($clientId);
 }
Exemple #5
0
 /**
  * Send an email with a list of attachments
  *
  * @param mixed $toEmail
  * @param mixed $subject
  * @param mixed $message
  * @param mixed $fromEmail
  * @param mixed $attachments
  */
 public static function sendEmailWithAttachments($toEmail, $subject, $message, $fromEmail = false, $attachments = array(), $ccEmail = false)
 {
     // We allow mutiple emails
     $emails = explode(',', $toEmail);
     $ccEmails = "";
     if (!empty($ccEmail)) {
         $ccEmails = explode(',', $ccEmail);
     }
     if (empty($emails)) {
         return false;
     }
     // Email with template
     $emailBody = $message ? $message : '';
     $emailSubject = $subject ? $subject : '';
     $emailAgent = new Mail_Mail('simple_text', $fromEmail ? false : true);
     $emailAgent->setBody($emailBody)->setSubject($emailSubject);
     if ($fromEmail) {
         $fromName = $fromEmail;
         $userObj = Repo_User::getInstance();
         $user_id = $userObj->emailExists($fromEmail);
         $_user = new Object_User($user_id);
         if (!$_user->getId()) {
             continue;
         }
         $userInfoArr = $_user->getBasicInfo();
         if (!empty($userInfoArr["firstname"]) || !empty($userInfoArr["surname"])) {
             $fromName = trim($userInfoArr["firstname"] . " " . $userInfoArr["surname"]);
         }
         $emailAgent->setFrom($fromName, $fromEmail);
     }
     if (!empty($attachments)) {
         foreach ($attachments as $_a) {
             // Add attachment
             $emailAgent->addAttachment($_a['path'], $_a['name']);
         }
     }
     if (!empty($ccEmail)) {
         foreach ($ccEmails as $_ccEmail) {
             $emailAgent->setCc($_ccEmail, $_ccEmail);
         }
     }
     foreach ($emails as $_toEmail) {
         $emailAgent->setTo($_toEmail);
     }
     try {
         $emailAgent->send();
     } catch (Exception $e) {
         // Ignore for now
     }
     return true;
 }