Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
 /**
  * Get session user/client info sololy based on session key.
  *
  * @return array Array of user and client array.
  */
 public function getSessionInfo()
 {
     $sessionKey = $this->_request->getParam('session');
     $keyRow = Repo_UserApiSessionKeys::getInstance()->getRow(array(array('where' => 'session_key = ?', 'bind' => $sessionKey)));
     if (!$keyRow || time() > $keyRow->modified + $keyRow->lifetime) {
         return false;
     }
     $user = new Object_User($keyRow->user_id);
     $client = new Object_Client($user->client_id);
     return array('user' => $user->getBasicInfo(), 'client' => $client->getDataArray());
 }
Ejemplo n.º 3
0
 /**
  * User detail page: edit/delete functionality.
  *
  * Also will include permissions, packages, groups etc.
  *
  * It is the central place for a user object.
  */
 public function userDetailAction()
 {
     $userId = $this->_request->getParam('id');
     $user = new Object_User($userId);
     $userId = $user->getId();
     if (empty($userId)) {
         // No user defined, redirec to list users.
         $this->_redirect('/admin/client/user');
         return false;
     }
     $form = new Form_Admin_Client_User_Create(false, array('user' => $user));
     // Check for user update
     if ($this->_request->isPost()) {
         $params = $this->_request->getPost();
         if ($form->isValid($params)) {
             // Update user if necessary
             $form->updateUser($user);
             $form->setUser($user);
         } else {
             $form->populate($params);
         }
     }
     $emailSignatureId = Repo_UserEmailSignature::getInstance()->getIdByUserId($userId);
     $this->view->userEmailSignature = new Object_UserEmailSignature($emailSignatureId);
     $this->view->emailSignatureId = $emailSignatureId;
     $this->view->user = $user;
     $this->view->client = new Object_Client($user->client_id);
     $this->view->form = $form;
     $this->view->userPackages = Repo_UserPackage::getInstance()->getUserPackages($userId);
     $this->view->userTeams = Repo_TeamUser::getInstance()->getUserTeams($userId);
     $this->view->userApps = Repo_AppUser::getInstance()->getUserApps($userId);
     $this->view->userDeviceIds = Repo_UserDevice::getInstance()->getUserDeviceIds($userId);
 }