Beispiel #1
0
 protected function _generatePasswords()
 {
     $save = false;
     $device = $this->getDevice();
     if (!$device->getStorePass()) {
         $device->setStorePass(Core_Model_Lib_String::generate(8));
         $save = true;
     }
     if (!$device->getKeyPass()) {
         $device->setKeyPass(Core_Model_Lib_String::generate(8));
         $save = true;
     }
     if (!$device->getAlias()) {
         $alias = Core_Model_Lib_String::format($this->getApplication()->getName(), true);
         if (!$alias) {
             $alias = $this->getApplication()->getId();
         }
         $device->setAlias($alias);
         $save = true;
     }
     if ($save) {
         $device->save();
     }
     return $this;
 }
Beispiel #2
0
 protected function _cpFolder()
 {
     $formatted_name = Core_Model_Lib_String::format($this->getApplication()->getName(), true);
     if (!$formatted_name) {
         $formatted_name = $this->getApplication()->getId();
         $zip_name = $formatted_name;
     } else {
         $zip_name = $formatted_name;
         $formatted_name .= "-" . $this->getApplication()->getId();
     }
     $src = Core_Model_Directory::getBasePathTo(self::SOURCE_FOLDER);
     if ($this->getDevice()->getExcludeAds()) {
         $src .= " No Ads";
     }
     $dst = Core_Model_Directory::getBasePathTo(self::DEST_FOLDER);
     $dst = sprintf($dst, $formatted_name);
     // Supprime le dossier s'il existe puis le créé
     if (is_dir($dst)) {
         Core_Model_Directory::delete($dst);
     }
     mkdir($dst, 0775, true);
     // Copie les sources
     Core_Model_Directory::duplicate($src, $dst);
     $this->_zipname = $zip_name . '_ios_source';
     $this->_dst = $dst . '/Apps Mobile Company';
     $this->_base_dst = $dst;
     return $this;
 }
 public function postAction()
 {
     if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
         try {
             if (empty($data['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             if (!Zend_Validate::is($data['email'], 'EmailAddress')) {
                 throw new Exception($this->_('Please enter a valid email address'));
             }
             $customer = new Customer_Model_Customer();
             $customer->find(array('email' => $data['email'], "app_id" => $this->getApplication()->getId()));
             if (!$customer->getId()) {
                 throw new Exception("Your email address does not exist");
             }
             $admin_email = null;
             $password = Core_Model_Lib_String::generate(8);
             $contact = new Contact_Model_Contact();
             $contact_page = $this->getApplication()->getPage('contact');
             if ($contact_page->getId()) {
                 $contact->find($contact_page->getId(), 'value_id');
                 $admin_email = $contact->getEmail();
             }
             $customer->setPassword($password)->save();
             $sender = 'no-reply@' . Core_Model_Lib_String::format($this->getApplication()->getName(), true) . '.com';
             $layout = $this->getLayout()->loadEmail('customer', 'forgot_password');
             $layout->getPartial('content_email')->setCustomer($customer)->setPassword($password)->setAdminEmail($admin_email)->setApp($this->getApplication()->getName());
             $content = $layout->render();
             $mail = new Zend_Mail('UTF-8');
             $mail->setBodyHtml($content);
             $mail->setFrom($sender, $this->getApplication()->getName());
             $mail->addTo($customer->getEmail(), $customer->getName());
             $mail->setSubject($this->_('%s - Your new password', $this->getApplication()->getName()));
             $mail->send();
             $html = array("success" => 1, "message" => $this->_("Your new password has been sent to the entered email address"));
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
     return $this;
 }
 protected function _sendNewAccountEmail($customer, $password)
 {
     $admin_email = null;
     $contact = new Contact_Model_Contact();
     $contact_page = $this->getApplication()->getPage('contact');
     $sender = 'no-reply@' . Core_Model_Lib_String::format($this->getApplication()->getName(), true) . '.com';
     if ($contact_page->getId()) {
         $contact->find($contact_page->getId(), 'value_id');
         $admin_email = $contact->getEmail();
     }
     $layout = $this->getLayout()->loadEmail('customer', 'create_account');
     $layout->getPartial('content_email')->setCustomer($customer)->setPassword($password)->setAdminEmail($admin_email)->setApp($this->getApplication()->getName());
     $content = $layout->render();
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyHtml($content);
     $mail->setFrom($sender, $this->getApplication()->getName());
     $mail->addTo($customer->getEmail(), $customer->getName());
     $mail->setSubject($this->_('%s - Account creation', $this->getApplication()->getName()));
     $mail->send();
     return $this;
 }
Beispiel #5
0
 protected function _cpFolder()
 {
     $this->_formatted_name = Core_Model_Lib_String::format($this->getApplication()->getName(), true);
     $this->_formatted_bundle_name = $this->_formatted_name;
     $src = Core_Model_Directory::getBasePathTo(self::SOURCE_FOLDER);
     $dst = Core_Model_Directory::getBasePathTo(self::DEST_FOLDER);
     // Supprime le dossier s'il existe puis le créé
     if (is_dir($dst)) {
         Core_Model_Directory::delete($dst);
     }
     mkdir($dst, 0775, true);
     // Copie les sources
     Core_Model_Directory::duplicate($src, $dst);
     $this->_zipname = 'android_source';
     $this->_dst = $dst;
     $src = $this->_dst . '/src/com/siberian/app';
     $dst = $this->_dst . '/src/com/' . $this->_formatted_bundle_name . '/' . $this->_formatted_name;
     Core_Model_Directory::move($src, $dst);
     Core_Model_Directory::delete($this->_dst . '/src/com/siberian');
     return $this;
 }
 public function uploadiconAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             $uploader = new Core_Model_Lib_Uploader();
             $file = $uploader->savecrop($datas);
             if (!empty($file)) {
                 $option_value = new Application_Model_Option_Value();
                 $option_value->find($datas['option_id']);
                 $lib = new Media_Model_Library();
                 $lib->find($option_value->getLibraryId());
                 $library_name = $lib->getName();
                 $formated_library_name = Core_Model_Lib_String::format($library_name, true);
                 $base_lib_path = Media_Model_Library_Image::getBaseImagePathTo($formated_library_name);
                 $files = Core_Model_Directory::getTmpDirectory(true) . '/' . $file;
                 $CanBeColorized = $datas['is_colorized'] == 'true' ? 1 : 0;
                 if (!is_dir($base_lib_path)) {
                     mkdir($base_lib_path, 0777, true);
                 }
                 if (!copy($files, $base_lib_path . '/' . $file)) {
                     throw new exception($this->_('An error occurred while saving your picture. Please try againg later.'));
                 } else {
                     $icon_lib = new Media_Model_Library_Image();
                     $icon_lib->setLibraryId($option_value->getLibraryId())->setLink('/' . $formated_library_name . '/' . $file)->setOptionId($option_value->getOptionId())->setAdminId($this->getSession()->getAdmin()->getId())->setCanBeColorized($CanBeColorized)->setPosition(0)->save();
                     $option_value->setIcon('/' . $formated_library_name . '/' . $file)->setIconId($icon_lib->getImageId())->save();
                     $icon_saved = $this->setIcon($icon_lib->getImageId(), $datas['option_id']);
                     // Charge l'option_value
                     $option_value = new Application_Model_Option_Value();
                     $option_value->find($datas['option_id']);
                     $icon_color = $this->getApplication()->getDesignBlock('tabbar')->getImageColor();
                     $html = array('success' => 1, 'file' => '/' . $formated_library_name . '/' . $file, 'icon_id' => $icon_lib->getImageId(), 'colorizable' => $CanBeColorized, 'icon_url' => Media_Model_Library_Image::getImagePathTo($formated_library_name . '/' . $file), 'colored_icon_url' => $this->getUrl('template/block/colorize', array('id' => $option_value->getIconId(), 'color' => str_replace('#', '', $icon_color))), 'colored_header_icon_url' => $icon_saved['colored_header_icon_url'], 'message' => '', 'message_button' => 1, 'message_loader' => 1);
                 }
             }
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }
 public function loginwithfacebookAction()
 {
     if ($access_token = $this->getRequest()->getParam('token')) {
         try {
             // Reset session
             $this->getSession()->resetInstance();
             // Fetch data from Facebook
             $graph_url = "https://graph.facebook.com/me?fields=id,name,email,first_name,last_name&access_token=" . $access_token;
             $user = json_decode(file_get_contents($graph_url));
             if (!$user instanceof stdClass or !$user->id) {
                 throw new Exception($this->_('An error occurred while connecting to your Facebook account. Please try again later'));
             }
             // Retrieve the user_id
             $user_id = $user->id;
             // Retrieve the current app ID
             $app_id = $this->getApplication()->getId();
             // Load the customer from the user_id
             $customer = new Customer_Model_Customer();
             $customer->findBySocialId($user_id, 'facebook', $app_id);
             // If the customer doesn't exist
             if (!$customer->getId()) {
                 // Load the customer based on the email address in order to link the 2 accounts together
                 if ($user->email) {
                     $customer->find(array("email" => $user->email, "app_id" => $app_id));
                 }
                 // If the email doesn't exist, create the account
                 if (!$customer->getId()) {
                     // Préparation des données du client
                     $customer->setData(array("app_id" => $app_id, "firstname" => $user->first_name, "lastname" => $user->last_name, "email" => $user->email));
                     // Add a default password
                     $customer->setPassword(uniqid());
                     // Retrieve its picture from Facebook
                     $social_image = @file_get_contents("http://graph.facebook.com/{$user_id}/picture?type=large");
                     if ($social_image) {
                         $formated_name = Core_Model_Lib_String::format($customer->getName(), true);
                         $image_path = $customer->getBaseImagePath() . '/' . $formated_name;
                         // Create customer's folder
                         if (!is_dir($customer->getBaseImagePath())) {
                             mkdir($image_path, 0777);
                         }
                         // Store the picture on the server
                         $image_name = uniqid() . '.jpg';
                         $image = fopen($image_path . '/' . $image_name, 'w');
                         fputs($image, $social_image);
                         fclose($image);
                         // Resize the image
                         Thumbnailer_CreateThumb::createThumbnail($image_path . '/' . $image_name, $image_path . '/' . $image_name, 150, 150, 'jpg', true);
                         // Set the image to the customer
                         $customer->setImage('/' . $formated_name . '/' . $image_name);
                     }
                 }
             }
             // Set the social data to the customer
             $customer->setSocialData('facebook', array('id' => $user_id, 'datas' => $access_token));
             // Save the customer
             $customer->save();
             // Log-in the customer
             $this->getSession()->setCustomer($customer);
             $html = array('success' => 1, 'customer_id' => $customer->getId(), 'can_access_locked_features' => $customer->canAccessLockedFeatures());
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
 }