/**
  * @param  DownloadTokenModel $downloadToken
  * @return DownloadTokenModel
  */
 public function create(models\ModelAbstract $downloadToken)
 {
     if (!$downloadToken instanceof DownloadTokenModel) {
         throw new InvalidArgumentException('Supplied data must be a download token model');
     }
     $downloadToken->token = UserService::getInstance()->generatePassword(60);
     $brandService = BrandService::getInstance();
     $brand = $brandService->loadByOrganization(\App::getOrgUserLogged());
     $router = \Zend_Controller_Front::getInstance()->getRouter();
     $downloadToken->url = $brand->endPoint . $router->assemble(array('controller' => $downloadToken->controller, 'action' => $downloadToken->action, 'token' => $downloadToken->token), 'downloadToken');
     $downloadToken->orgId = \App::getOrgUserLogged()->getId();
     $downloadToken->expireDatetime = \App::config('downloadTokenLifeTime', "+1 day");
     $ident = \Zend_Auth::getInstance()->getIdentity();
     if (isset($ident['username'])) {
         $downloadToken->username = $ident['username'];
     }
     if (isset($ident['authType'])) {
         $downloadToken->authType = $ident['authType'];
     }
     if (isset($ident['apiId'])) {
         $downloadToken->apiId = $ident['apiId'];
     }
     if (isset($ident['impersonation'])) {
         $downloadToken->impersonation = $ident['impersonation'];
     }
     return parent::create($downloadToken);
 }
Example #2
0
 public function getList()
 {
     $service = BrandService::getInstance();
     $brands = $service->listAll()->getItems();
     $result = array();
     foreach ($brands as $brand) {
         if ($brand->getBrand() !== BrandModel::DEFAULT_BRAND) {
             $result[] = $brand->getBrand();
         }
     }
     return $result;
 }
 protected function _createMail(UserModel $user, $brand = null)
 {
     if (\App::get('mail') === null) {
         throw new UnexpectedException('No mail transport configured');
     }
     $fullName = $user->getFirstName() . ' ' . $user->getLastName();
     // Creating / configuring email object.
     $mail = new \App_Mail('UTF-8');
     $mail->setLocale($user->getLanguage());
     $mail->addTo($user->getEmail(), $fullName);
     $view = $mail->getView();
     $view->fullName = $fullName;
     $view->userName = $user->userName;
     $view->user = $user;
     // Configure brand mail folder
     if (!$brand || !$brand instanceof BrandModel) {
         $brandService = BrandService::getInstance();
         $brand = $brandService->loadByUser($user);
     }
     if (!$brand || !$brand instanceof BrandModel) {
         throw new NotFoundException("Brand not found for user " . $user->id);
     }
     $mail->setScriptNamespace($brand->getScriptNamespace());
     $view->setBaseUrl($brand->getEndPoint());
     $view->setImageNamespace($brand->getImageNamespace());
     $view->brand = $brand;
     \App::log()->debug("Sending an email using '" . $brand->brand . "' brand");
     return $mail;
 }