Ejemplo n.º 1
0
 public function loginAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         $canBeLoggedIn = false;
         try {
             if (empty($datas['email']) or empty($datas['password'])) {
                 throw new Exception($this->_('Authentification impossible. Merci de vérifier votre email et/ou votre mot de passe'));
             }
             $admin = new Admin_Model_Admin();
             $admin->findByEmail($datas['email']);
             if ($admin->authenticate($datas['password'])) {
                 $application = $this->getApplication();
                 $datas = array('applications' => array());
                 $url = parse_url($application->getUrl());
                 $url['path'] = 'overview';
                 $icon = '';
                 if ($application->getIcon()) {
                     $icon = $this->getRequest()->getBaseUrl() . $application->getIcon();
                 }
                 $datas['application'] = array('id' => $application->getId(), 'icon' => $icon, 'startup_image' => $application->getStartupImageUrl(), 'startup_image_retina' => $application->getStartupImageUrl('retina'), 'name' => $application->getName(), 'scheme' => $url['scheme'], 'host' => $url['host'], 'path' => ltrim($url['path'], '/'), 'url' => $application->getUrl());
             } else {
                 throw new Exception($this->_('Authentification impossible. Merci de vérifier votre email et/ou votre mot de passe'));
             }
         } catch (Exception $e) {
             $datas = array('error' => $this->_('Authentification impossible. Merci de vérifier votre email et/ou votre mot de passe'));
             //                $datas = array('error' => $e->getMessage());
         }
         $this->getResponse()->setBody(Zend_Json::encode($datas))->sendResponse();
         die;
     }
 }
 public function listAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         try {
             if (empty($data["admin_id"])) {
                 throw new Exception($this->_("The admin_id parameter is required"));
             }
             $admin = new Admin_Model_Admin();
             $admin->find($data["admin_id"]);
             if (!$admin->getId()) {
                 throw new Exception($this->_("This admin does not exist"));
             }
             $applications = array();
             foreach ($admin->getApplications() as $application) {
                 if (!$application->isActive()) {
                     continue;
                 }
                 $icon = null;
                 if ($application->getIcon()) {
                     $icon = $this->getRequest()->getBaseUrl() . $application->getIcon();
                 }
                 $application->addData(array("url" => $application->getUrl(), "icon" => $icon, 'startup_image_url' => str_replace("//", "/", $this->getRequest()->getBaseUrl() . $application->getStartupImageUrl()), 'retina_startup_image_url' => str_replace("//", "/", $this->getRequest()->getBaseUrl() . $application->getStartupImageUrl("retina"))));
                 $applications[] = $application->getData();
             }
             $data = array("success" => 1, "applications" => $applications);
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
Ejemplo n.º 3
0
 public function createAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         try {
             if (isset($data["id"])) {
                 unset($data["id"]);
             }
             if (isset($data["app_id"])) {
                 unset($data["app_id"]);
             }
             if (empty($data["name"])) {
                 throw new Exception($this->_("The name is required"));
             }
             if (empty($data["user_id"])) {
                 throw new Exception($this->_("This admin does not exist"));
             }
             $admin = new Admin_Model_Admin();
             $admin->find($data["user_id"]);
             if (!$admin->getId()) {
                 throw new Exception($this->_("This admin does not exist"));
             }
             $application = new Application_Model_Application();
             $this->__checkKeyAndDomain($data, $application);
             $application->addData($data)->addAdmin($admin)->save();
             $data = array("success" => 1, "app_id" => $application->getId(), "app_url" => $application->getUrl());
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
Ejemplo n.º 4
0
 public function saveAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             $message = '';
             // Récupère le commerçe en cours
             $admin = $this->getSession()->getAdmin();
             if (empty($datas['url_key'])) {
                 throw new Exception($this->_('Please enter a subdomain.'));
             }
             if (preg_match("#[^a-z0-9]#", $datas['url_key'])) {
                 throw new Exception($this->_('Your mobile address should not contain special characters'));
             }
             $dummy = new Admin_Model_Admin();
             if ($dummy->find($datas['url_key'], 'url_key')->getId()) {
                 throw new Exception($this->_('We are sorry but this address is already used.'));
             }
             $admin->setUrlKey($datas['url_key'])->save();
             $html = array('success' => '1', 'success_message' => $message, 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0);
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage());
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }
Ejemplo n.º 5
0
 public function findAction()
 {
     $application = Application_Model_Application::getInstance();
     $admin = new Admin_Model_Admin();
     if (Siberian_Version::is("sae")) {
         $admins = $admin->findAll()->toArray();
         $admin_owner = $admin;
         $admin_owner->setData(current($admins));
     } else {
         $admins = $admin->getAllApplicationAdmins($this->getRequest()->getParam("app_id"));
         $admin_owner = $application->getOwner();
     }
     $admin_list = array();
     foreach ($admins as $admin) {
         $admin_list[] = $admin;
     }
     $admin = array("name" => $admin_owner->getFirstname() . " " . $admin_owner->getLastname(), "email" => $admin_owner->getEmail(), "company" => $admin_owner->getCompany(), "phone" => $admin_owner->getPhone());
     $store_categories = Application_Model_Device_Ios::getStoreCategeories();
     $devices = array();
     foreach ($application->getDevices() as $device) {
         $device->setName($device->getName());
         $device->setBrandName($device->getBrandName());
         $device->setStoreName($device->getStoreName());
         $device->setHasMissingInformation(!$device->getUseOurDeveloperAccount() && (!$device->getDeveloperAccountUsername() || !$device->getDeveloperAccountPassword()));
         $devices[] = $device->getData();
     }
     $data = array('admin' => $admin, 'admin_list' => $admin_list, 'app_store_icon' => $application->getAppStoreIcon(), 'google_play_icon' => $application->getGooglePlayIcon(), 'devices' => $devices, 'url' => $application->getUrl(), 'has_ios_certificate' => Push_Model_Certificate::getiOSCertificat() !== null);
     foreach ($store_categories as $name => $store_category) {
         if ($store_category->getId() == $application->getMainCategoryId()) {
             $data['main_category_name'] = $name;
         } else {
             if ($store_category->getId() == $application->getSecondaryCategoryId()) {
                 $data['secondary_category_name'] = $name;
             }
         }
     }
     $folder_name = $application->getDevice(2)->getTmpFolderName();
     $apk_path = null;
     $date_mod = null;
     if ($folder_name != "") {
         $apk_base_path = Core_Model_Directory::getBasePathTo("var/tmp/applications/android/{$folder_name}/Siberian/app/build/outputs/apk/app-release.apk");
     }
     if (file_exists($apk_base_path)) {
         $apk_path = Core_Model_Directory::getPathTo("var/tmp/applications/android/{$folder_name}/Siberian/app/build/outputs/apk/app-release.apk");
         $date = new Zend_Date(filemtime($apk_base_path), Zend_Date::TIMESTAMP);
         $date_mod = $date->toString($this->_("MM/dd/y 'at' hh:mm a"));
     }
     $data["bundle_id"] = $application->getBundleId();
     $data["is_active"] = $application->isActive();
     $data["is_locked"] = $application->isLocked();
     $data["can_be_published"] = $application->canBePublished();
     if ($application->getFreeUntil()) {
         $date = new Zend_Date($application->getFreeUntil(), Zend_Date::ISO_8601);
         $data["free_until"] = $date->toString("MM/dd/yyyy");
     }
     $data["apk"] = array("link" => $apk_path, 'date' => $date_mod);
     $application->addData($data);
     $data = array("application" => $application->getData(), 'statuses' => Application_Model_Device::getStatuses());
     $this->_sendHtml($data);
 }
Ejemplo n.º 6
0
 public function findAction()
 {
     $notification = new Backoffice_Model_Notification();
     $unread_number = $notification->findAll(array("is_read = ?" => 0))->count();
     $unread_message = $unread_number > 1 ? $this->_("%d Unread Messages", $unread_number) : $this->_("%d Unread Message", $unread_number);
     $admin = new Admin_Model_Admin();
     $admins = $admin->getStats();
     $array_admin = array();
     foreach ($admins as $admin) {
         $array_admin[$admin->getDay()] = $admin->getCount();
     }
     $dateKey = new Siberian_Date();
     $dateEnd = new Siberian_Date();
     $dateKey = $dateKey->setDay(1);
     $dateEnd = $dateEnd->setDay(1);
     $dateEnd->addMonth(1);
     $dateEnd = $dateEnd->subDay(1);
     $stats = array();
     $i = 0;
     while (strcmp($dateKey->toString("yyyy-MM-dd"), $dateEnd->toString("yyyy-MM-dd")) <= 0) {
         $admin = isset($array_admin[$dateKey->toString("yyyy-MM-dd")]) ? $array_admin[$dateKey->toString("yyyy-MM-dd")] : 0;
         $stats[] = array($dateKey->toString("EEE. MMM, dSS"), $admin);
         $dateKey->addDay(1);
     }
     $data = array("stats" => $stats, "notif" => array("unread_number" => $unread_number, "message" => $unread_message));
     $this->_sendHtml($data);
 }
Ejemplo n.º 7
0
 public function canPublishThemself()
 {
     $publication_type = System_Model_Config::getValueFor("system_publication_access_type");
     $admin = new Admin_Model_Admin();
     $admin->find($this->getApplication()->getAdminId());
     $publish_rights = $admin->getPublicationAccessType() ? $admin->getPublicationAccessType() : $publication_type;
     return $publish_rights == 'sources';
 }
Ejemplo n.º 8
0
 /**
  * Find admin
  *
  * @param int $applicationId
  * @param string $username
  * @param Admin_Model_Admin $admin
  * @return boolean
  */
 public function find($applicationId, $username, Admin_Model_Admin $admin)
 {
     $select = $this->_dbTable->select();
     $select->setIntegrityCheck(false)->from(array('a' => 'admin'), array('a.*'))->joinLeft(array("aa" => "admin_application"), "aa.admin_id = a.id")->where('a.username = ?', $username)->where('aa.application_id = ?', $applicationId);
     $resultSet = $this->_dbTable->fetchAll($select);
     if (0 == count($resultSet)) {
         return false;
     }
     //get first row from resultSet
     $row = $resultSet->current();
     $admin->setOptions($row->toArray());
     return true;
 }
Ejemplo n.º 9
0
 public function loginAction()
 {
     try {
         $data = $this->getRequest()->getPost();
         if (!$this->getRequest()->isPost()) {
             $data = Zend_Json::decode($this->getRequest()->getRawBody());
             $this->getResponse()->setHeader("Access-Control-Allow-Credentials", true, true);
             $this->getResponse()->setHeader("Access-Control-Allow-Methods", "PUT", true);
             $this->getResponse()->setHeader("Access-Control-Allow-Origin", "*", true);
             $this->getResponse()->setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Pragma", true);
         }
         if (!empty($data)) {
             $canBeLoggedIn = false;
             if (empty($data['email']) or empty($data['password'])) {
                 throw new Exception($this->_('Authentication failed. Please check your email and/or your password'));
             }
             $admin = new Admin_Model_Admin();
             $admin->findByEmail($data['email']);
             if ($admin->authenticate($data['password'])) {
                 $applications = $admin->getApplications();
                 $data = array('applications' => array());
                 foreach ($applications as $application) {
                     if (!$application->isActive()) {
                         continue;
                     }
                     $url = parse_url($application->getUrl());
                     $key = "";
                     if (stripos($url["path"], $application->getKey())) {
                         $url["path"] = str_replace($application->getKey(), "", $url["path"]);
                         $key = $application->getKey();
                     }
                     $icon = '';
                     if ($application->getIcon()) {
                         $icon = $this->getRequest()->getBaseUrl() . $application->getIcon();
                     }
                     $data['applications'][] = array('id' => $application->getId(), 'icon' => $icon, 'startup_image' => str_replace("//", "/", $application->getStartupImageUrl()), 'startup_image_retina' => str_replace("//", "/", $application->getStartupImageUrl("retina")), 'name' => $application->getName(), 'scheme' => $url['scheme'], 'domain' => $url['host'], 'path' => ltrim($url['path'], '/'), 'key' => $key, 'url' => $application->getUrl());
                 }
             } else {
                 throw new Exception($this->_('Authentication failed. Please check your email and/or your password'));
             }
         }
     } catch (Exception $e) {
         $data = array('error' => $this->_('Authentication failed. Please check your email and/or your password'));
     }
     $this->getResponse()->setBody(Zend_Json::encode($data))->sendResponse();
     die;
 }
 public function deleteAction()
 {
     if ($admin_id = $this->getRequest()->getParam('admin_id')) {
         try {
             $admin = new Admin_Model_Admin();
             $admin->find($admin_id);
             if (!$admin->getId()) {
                 throw new Exception($this->_("This administrator does not exist"));
             }
             $admin->delete();
             $html = array('success' => 1, 'admin_id' => $admin_id);
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
 }
Ejemplo n.º 11
0
 public function saveAction()
 {
     if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
         try {
             if (!Zend_Validate::is($data["email"], "emailAddress")) {
                 throw new Exception($this->_("Please, enter a correct email address."));
             }
             $admin = new Admin_Model_Admin();
             $dummy = new Admin_Model_Admin();
             $dummy->find($data["email"], "email");
             $isNew = true;
             $data["confirm_password"] = !empty($data["confirm_password"]) ? $data["confirm_password"] : "";
             if (!empty($data["id"])) {
                 $admin->find($data["id"]);
                 $isNew = !$admin->getId();
             }
             if ($isNew and empty($data["password"])) {
                 throw new Exception($this->_("Please, enter a password."));
             }
             if (empty($data["password"]) and empty($data["confirm_password"])) {
                 unset($data["password"]);
                 unset($data["confirm_password"]);
             }
             if (!empty($data["password"]) and $data["password"] != $data["confirm_password"]) {
                 throw new Exception($this->_("Passwords don't match"));
             }
             $admin->addData($data);
             if ($dummy->getEmail() == $admin->getEmail() and $dummy->getId() != $admin->getId()) {
                 throw new Exception($this->_("We are sorry but this email address already exists."));
             }
             if (!empty($data["password"])) {
                 $admin->setPassword($data["password"]);
             }
             if (!empty($data["publication_access_type"])) {
                 $admin->setPublicationAccessType($data["publication_access_type"]);
             }
             $admin->save();
             $data = array("success" => 1, "message" => $this->_("User successfully saved"));
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
Ejemplo n.º 12
0
 public function setaddpageAction()
 {
     if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
         try {
             if (empty($data["admin_id"]) or empty($data["app_id"])) {
                 throw new Exception($this->_("An error occurred while saving. Please try again later."));
             }
             $admin = new Admin_Model_Admin();
             $admin->find($data["admin_id"]);
             $application = new Application_Model_Application();
             $application->find($data["app_id"]);
             if (!$admin->getId() or !$application->getId()) {
                 throw new Exception($this->_("An error occurred while saving. Please try again later."));
             }
             $admin->setIsAllowedToAddPages(!empty($data["can_add_page"]))->save();
             $data = array("success" => 1, "message" => $this->_("Data saved successfully."));
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
Ejemplo n.º 13
0
 public function createAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         $admin = new Admin_Model_Admin();
         try {
             if (empty($datas['email']) or empty($datas['password']) or empty($datas['confirm_password'])) {
                 throw new Exception($this->_('Please, fill out all fields'));
             }
             if (!Zend_Validate::is($datas['email'], 'emailAddress')) {
                 throw new Exception($this->_('Please enter a valid email address'));
             }
             if ($datas['password'] != $datas['confirm_password']) {
                 throw new Exception($this->_("The entered password confirmation does not match the entered password."));
             }
             $admin->setData($datas)->setPassword($datas['password'])->save();
             $this->getSession()->setAdmin($admin);
             $html = array('success' => 1);
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage());
             $this->getResponse()->setHttpResponseCode(400);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }
Ejemplo n.º 14
0
 public function loginasAction()
 {
     if ($admin_id = $this->getRequest()->getParam("admin_id")) {
         $admin = new Admin_Model_Admin();
         $admin->find($admin_id);
         if ($admin->getId()) {
             $key = sha1($admin->getFirstname() . $admin->getId());
             if ($key == $this->getRequest()->getParam('key', 'aa')) {
                 $front_session = $this->getSession('front');
                 $front_session->resetInstance()->setAdmin($admin);
                 $this->_redirect('');
                 return $this;
             }
         }
     }
 }
 public function editAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('NODEID', -1);
     $ntid = $request->getParam('NODETYPEID');
     Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
     $this->view->addHelperPath('Uman/Dojo/View/Helper/', 'Uman_Dojo_View_Helper');
     $form = new Uman_Admin_Form();
     $form->setName('nodeEditorForm');
     $form->setAttrib('jsId', 'nodeEditorForm');
     $form->setAction('/admin/editor/save');
     $form->setMethod('post');
     $form->setEnctype('multipart/form-data');
     $dbModel = new Admin_Model_Admin();
     $nodeeditorInfo = $dbModel->getNodeEditorInfo($ntid);
     $fields = $dbModel->getEditorFields($nodeeditorInfo['DEFAULT_EDITOR_NODEID']);
     $parentidExists = false;
     $nodetypeidExists = false;
     $js_oncreate = '';
     $js_beforesubmit = '';
     foreach ($fields as $field) {
         if (!$field['VISIBLE']) {
             continue;
         }
         if ($field['FIELDNAME'] == 'PARENTID') {
             $parentidExists = true;
         } else {
             if ($field['FIELDNAME'] == 'NODETYPEID') {
                 $nodetypeidExists = true;
             }
         }
         $class = $field['ELEMENT_CLASS'];
         $e = new $class($field['FIELDNAME']);
         //			$e->setName($fieldName);
         if (!empty($field['ELEMENT_CONFIG'])) {
             /*
              * In php.ini must be:
              * allow_url_include = on;
              * allow_url_fopen = on;
             */
             $elem_cfg = new Zend_Config_Ini('data://,' . $field['ELEMENT_CONFIG']);
             $elem_cfg = $elem_cfg->toArray();
             $e->setOptions($elem_cfg);
         }
         $e->setLabel($field['TITLE']);
         //			if (@$field['REQUIRED'])
         $e->setRequired($field['REQUIRED']);
         switch ($class) {
             case 'Zend_Form_Element_Hidden':
                 $decor = array('ViewHelper');
                 break;
             case 'Zend_Form_Element_File':
                 //				$e->setMaxFileSize(1024);
                 $decor = $form->elementFileDecorators;
                 break;
             default:
                 $decor = $form->elementDecorators;
         }
         $e->setDecorators($decor);
         $form->addElement($e);
         $js_oncreate .= isset($field['JS_ONCREATE']) ? $field['JS_ONCREATE'] . "\n" : '';
         $js_beforesubmit .= isset($field['JS_BEFORESUBMIT']) ? $field['JS_BEFORESUBMIT'] . "\n" : '';
     }
     $e = new Zend_Dojo_Form_Element_SubmitButton('save', array('label' => 'Сохранить'));
     $e->setDecorators($form->buttonDecorators);
     $form->addElement($e);
     /*		$e = new Zend_Dojo_Form_Element_Button('cancel', array('label' => 'Отмена', 'onClick' => "dijit.byId('editorDialog').onCancel()"));
     		$e->setDecorators($form->buttonDecorators);
     		$form->addElement($e);*/
     $form->addElements(array($form->createElement('hidden', 'NODEID')->setDecorators(array('ViewHelper')), $form->createElement('hidden', 'MODE')->setDecorators(array('ViewHelper'))));
     if (!$nodetypeidExists) {
         $form->addElement($form->createElement('hidden', 'NODETYPEID')->setDecorators(array('ViewHelper')));
     }
     if (!$parentidExists) {
         $form->addElement($form->createElement('hidden', 'PARENTID')->setDecorators(array('ViewHelper')));
     }
     if ($request->isPost()) {
         $res = $form->processAjax($request->getPost());
         if ($res != 'true') {
             echo $res;
             exit;
         } else {
             //			if($form->isValid ( $request->getPost () )) {
             $dbModel->saveFieldsValues($fields, $request->getPost(), $nodeeditorInfo);
             //				$dbModel->copyResources ( $id, false );
             echo $res;
             // "<textarea>$res</textarea"; //OK for AJAX request
             exit;
         }
     } else {
         if ($id == -1) {
             // New page
             $pid = $request->getParam('PARENTID');
             $dbModel->checkRight($pid);
             $id = $dbModel->getNextId('GEN_TEMP_UID');
             $values = array_merge($dbModel->getNewValues($fields, $nodeeditorInfo), array('NODEID' => $id, 'PARENTID' => $pid, 'NODETYPEID' => $ntid, 'MODE' => 'ADD', 'SORTORDER' => $dbModel->getNextSortOrder($pid)));
             //				mkdir($this->_cfg['temp']['path'] . $id);
         } else {
             $dbModel->checkRight($id);
             $values = array_merge($dbModel->getFieldsValues($fields, $id, $nodeeditorInfo), array('MODE' => 'EDIT'));
             $dbModel->copyResources($id, $id, true);
         }
         $form->populate($values);
         $this->view->assign('form', $form);
         $this->view->assign('title', $nodeeditorInfo['TITLE']);
         if (!empty($js_oncreate)) {
             $this->view->assign('js_oncreate', $js_oncreate);
             $this->view->assign('id', $id);
             $this->view->assign('baseUrl', $request->getBaseUrl());
         }
         if (!empty($js_beforesubmit)) {
             $this->view->assign('js_beforesubmit', $js_beforesubmit);
         }
     }
 }
Ejemplo n.º 16
0
 public function getOwner()
 {
     $admin = new Admin_Model_Admin();
     $admin->find($this->getAdminId());
     return $admin;
 }
Ejemplo n.º 17
0
 public function autologinAction()
 {
     if ($email = $this->getRequest()->getParam("email") and $token = $this->getRequest()->getParam("token")) {
         try {
             $admin = new Admin_Model_Admin();
             $admin->find($email, "email");
             if (!$admin->getId()) {
                 throw new Exception($this->_("The user doesn't exist."));
             }
             if ($admin->getLoginToken() != $token) {
                 throw new Exception($this->_("Authentication failed"));
             }
             $this->getSession()->setAdmin($admin);
             $this->_redirect("admin/application/list");
         } catch (Exception $e) {
         }
     }
 }
Ejemplo n.º 18
0
 public function forgotpasswordpostAction()
 {
     if ($datas = $this->getRequest()->getPost() and !$this->getSession()->isLoggedIn('admin') and !$this->getSession()->isLoggedIn('pos')) {
         try {
             if (empty($datas['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             $admin = new Admin_Model_Admin();
             $admin->findByEmail($datas['email']);
             if (!$admin->getId()) {
                 throw new Exception($this->_("Your email address does not exist"));
             }
             $password = Core_Model_Lib_String::generate(8);
             $admin->setPassword($password)->save();
             $sender = System_Model_Config::getValueFor("support_email");
             $support_name = System_Model_Config::getValueFor("support_name");
             $layout = $this->getLayout()->loadEmail('admin', 'forgot_password');
             $subject = $this->_('%s - Your new password', $support_name);
             $layout->getPartial('content_email')->setPassword($password);
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($sender, $support_name);
             $mail->addTo($admin->getEmail(), $admin->getName());
             $mail->setSubject($subject);
             $mail->send();
             $this->getSession()->addSuccess($this->_('Your new password has been sent to the entered email address'));
         } catch (Exception $e) {
             $this->getSession()->addError($e->getMessage());
         }
     }
     $this->_redirect('/');
     return $this;
 }
Ejemplo n.º 19
0
 public function getAllowedTypes($id)
 {
     $dbModel = new Admin_Model_Admin();
     return $dbModel->getAllowedTypes($id);
 }
 public function showAction()
 {
     set_time_limit(600);
     // 10 min
     //		ini_set('output_buffering', '4096');
     $nodeid = $this->getRequest()->getParam('id', -1);
     $this->_zip = new Uman_ZipStream("pack_{$nodeid}.pkg");
     $xml = new DomDocument('1.0', 'utf-8');
     $root = $xml->appendChild(new DOMElement('package'));
     $content = $xml->createElement('content');
     $content = $root->appendChild($content);
     $this->addLevel($this->_db->fetchAll($this->_rootsql, $nodeid), $content, $this->getRequest()->getParam('contentinc', false));
     $packid = $this->_db->nextSequenceId('GEN_UID');
     $this->addInfo($nodeid, $root, $packid);
     $this->addTypes($root);
     $this->_zip->add_file('info.xml', $xml->saveXML());
     $this->_zip->finish();
     $AdminDbModel = new Admin_Model_Admin();
     $AdminDbModel->exportPackage($nodeid, $packid);
     /*		header("Content-type: application/x-zip");
     		header("Content-Disposition: attachment; filename=test.zip");
     				
     		$zip = new ZipArchive();
     		if ($zip->open('php://output', ZIPARCHIVE::CREATE)!==TRUE) { // Пока не работает запись в поток
         	echo "cannot open \n";
         	exit;
     		}
     		$zip->addFromString('test.txt', '11111111111');
     		$zip->close();	
     */
     exit;
 }
Ejemplo n.º 21
0
 public function __construct($params)
 {
     $admin = new Admin_Model_Admin();
     $admin->find($params['id']);
     $this->setObject($admin);
 }
 private function import($zip)
 {
     if (!($xmlfile = $zip->getFromName($this->infoxmlfile))) {
         echo "file '" . $this->infoxmlfile . "' in the package not found";
         exit;
     } else {
         $xml = new SimpleXMLElement($xmlfile);
     }
     $time_start = microtime(1);
     $this->log = "Start log....\n";
     if (strcmp($this->packagetype, (string) $xml->packageinfo->packagetype) != 0) {
         echo "Package type error.\n Expected: '" . $this->packagetype . "', found: '" . (string) $xml->packageinfo->packagetype . "'.";
         exit;
     } else {
         $this->log .= "Package type: " . (string) $xml->packageinfo->packagetype . "\n";
     }
     if (strcmp($this->version, (string) $xml->packageinfo->version) != 0) {
         echo "Package version error.\n Expected: '" . $this->version . "', found: '" . (string) $xml->packageinfo->version . "'.";
         exit;
     } else {
         $this->log .= "Package version: " . (string) $xml->packageinfo->version . "\n";
     }
     if (strcmp("", (string) $xml->packageinfo->finalization) === 0) {
         echo "Package is not finalized";
         exit;
     }
     $packid = (string) $xml->packageinfo->packid;
     $sql = "select P.STATUS, P.PACKAGEID, CT.TITLE, P.EXPORTDATE, \n\t\tP.IMPORTDATE, IIU.USERNAME as IMPORTUSERNAME, \n\t\tEIU.USERNAME as EXPORTUSERNAME from PACKAGES P \n\t\tleft join CONTENTTREE CT   \n\t\ton (CT.NODEID = P.NODEID) \n\t\tleft join INFO_USERS IIU   \n\t\ton (IIU.NODEID = P.IMPORTUSERID) \n\t\tleft join INFO_USERS EIU   \n\t\ton (EIU.NODEID = P.EXPORTUSERID) \n\t\twhere P.PACKAGEID = ?";
     $res = $this->_db->fetchRow($sql, $packid);
     if (!$res) {
         echo "Export of package not found. Package id = " . $packid;
         exit;
     }
     if (trim($res['STATUS']) == $this->db_status_import) {
         echo "Package was imported. \n\t\t\tInformation: \n \n\t\t\texport from: " . $res['EXPORTDATE'] . " By: '" . $res['EXPORTUSERNAME'] . "'\n. \n\t\t\tImport from: " . $res['IMPORTDATE'] . " \n\t\t\tBy: '" . $res['IMPORTUSERNAME'] . "'\n for node title: " . $res['TITLE'] . "\n. Package ID: " . $res['PACKAGEID'];
         exit;
     } else {
         $this->log .= " Information: \n export from: " . $res['EXPORTDATE'] . " By: '" . $res['EXPORTUSERNAME'] . "'.\n for node title: " . $res['TITLE'] . "\n";
     }
     $this->_db->beginTransaction();
     $sql = "select RDB\$SET_CONTEXT('USER_TRANSACTION', 'CURRENT_USERID', ?) from RDB\$DATABASE";
     $this->_db->fetchCol($sql, $this->_acl->userid);
     $this->log .= "------------------------- begin\n";
     $this->importLevel($zip, $xml->content->children());
     $this->ImportLevelDel($zip, $xml->content->children());
     $this->log .= "------------------------- end\n";
     $time_end = microtime(1);
     $time = $time_end - $time_start;
     $this->log .= "-> Package load: " . $time . " sec";
     //
     $AdminDbModel = new Admin_Model_Admin();
     $AdminDbModel->importPackage($packid, (string) $xml->packageinfo->guid, $this->log, $this->db_status_import);
     $this->_db->commit();
     echo $this->log;
 }