コード例 #1
0
ファイル: Android.php プロジェクト: bklein01/siberian_cms_2
 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;
 }
コード例 #2
0
 public function forgottenpasswordAction()
 {
     if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
         try {
             if (empty($data['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             $user = new Backoffice_Model_User();
             $user->find($data['email'], 'email');
             if (!$user->getId()) {
                 throw new Exception($this->_("Your email address does not exist"));
             }
             $password = Core_Model_Lib_String::generate(8);
             $user->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->_('Your new password');
             $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($user->getEmail(), $user->getName());
             $mail->setSubject($subject);
             $mail->send();
             $data = array("success" => 1, "message" => $this->_('Your new password has been sent to the entered email address'));
         } catch (Exception $e) {
             $data = array("error" => 1, "message" => $e->getMessage());
         }
     }
     $this->_sendHtml($data);
 }
コード例 #3
0
ファイル: Ios.php プロジェクト: bklein01/siberian_cms_2
 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;
 }
コード例 #4
0
ファイル: Default.php プロジェクト: bklein01/siberian_cms_2
 public function __call($method, $args)
 {
     $accessor = substr($method, 0, 3);
     $magicKeys = array('set', 'get', 'uns', 'has');
     if (substr($method, 0, 12) == 'getFormatted') {
         $key = Core_Model_Lib_String::camelize(substr($method, 12));
         $data = $this->getData($key);
         if (preg_match('/^\\s*([0-9]+(\\.[0-9]+)?)\\s*$/', $data)) {
             return $this->formatPrice($data, !empty($args[0]) ? $args[0] : null);
         } elseif (preg_match('/(\\d){2,4}\\-(\\d){2}\\-(\\d){2}/', $data)) {
             return $this->formatDate($data, !empty($args[0]) ? $args[0] : null);
         }
     }
     if (in_array($accessor, $magicKeys)) {
         if (substr($method, 0, 7) == 'getOrig') {
             $key = Core_Model_Lib_String::camelize(substr($method, 7));
             $method = $accessor . 'OrigData';
         } else {
             $key = Core_Model_Lib_String::camelize(substr($method, 3));
             $method = $accessor . 'Data';
         }
         $value = isset($args[0]) ? $args[0] : null;
         return call_user_func(array($this, $method), $key, $value);
     }
     throw new Exception("Invalid method " . get_class($this) . "::" . $method . "(" . print_r($args, 1) . ")");
 }
コード例 #5
0
 public function findallAction()
 {
     if ($value_id = $this->getRequest()->getParam('value_id')) {
         $application = $this->getApplication();
         $comment = new Comment_Model_Comment();
         $comments = $comment->findLastest($value_id);
         $color = $application->getBlock('background')->getColor();
         $data = array("news" => array(), "application" => array());
         foreach ($comments as $comment) {
             $data['news'][] = array("text" => Core_Model_Lib_String::truncate($comment->getText(), 88), "created_at" => $comments->getFormattedCreatedAt(), "number_of_comments" => count($comment->getAnswers()), "number_of_likes" => count($comment->getLikes()));
         }
         $data['application'] = array("icon_url" => $application->getIconUrl(74), "name" => $application->getName());
         $data['picto'] = array("pencil" => $this->_getColorizedImage($this->getImage("picto/pencil.png"), $color), "comment" => $this->_getColorizedImage($this->getImage("picto/comment.png"), $color), "like" => $this->_getColorizedImage($this->getImage("picto/like.png"), $color));
         $this->_sendHtml($data);
     }
 }
コード例 #6
0
 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;
 }
コード例 #7
0
 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;
 }
コード例 #8
0
ファイル: Android.php プロジェクト: bklein01/SiberianCMS
 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;
 }
コード例 #9
0
 protected function _parseXml($lang_id)
 {
     $data = $translation_files_data = $translation_files = array();
     $lang_id = Core_Model_Lib_String::formatLanguageCodeForAndroid($lang_id);
     foreach ($this->_xml_files as $file) {
         if ($file["is_translatable"]) {
             $file_name = $file["name"];
             $user_translation_dir = $file["user_path"] . "values-" . $lang_id . DS;
             $default_base_path = $file["base_path"];
             $translation_file_name = $file["file_name"];
             $default_file = $default_base_path . $translation_file_name;
             $user_file = $user_translation_dir . $translation_file_name;
             $pathinfo = pathinfo($default_file);
             if (empty($pathinfo["extension"]) or $pathinfo["extension"] != "xml") {
                 return;
             }
             $translation_files[$file_name] = $file_name;
             $file_xml_data = simplexml_load_file($default_file);
             $user_file_xml_data = null;
             if (is_file($user_file)) {
                 $user_file_xml_data = simplexml_load_file($user_file);
             }
             $i = 0;
             foreach ($file_xml_data->children() as $string) {
                 if ((string) $string->attributes()->name != "app_name" && (string) $string->attributes()->name != "url") {
                     if (stripos((string) $string, '{#--') !== false) {
                         continue;
                     }
                     $key = str_replace("_", " ", ucfirst((string) $string->attributes()->name)) . " (e.g.: " . (string) $string . ")";
                     if ($user_file_xml_data != null) {
                         foreach ($user_file_xml_data as $user_string) {
                             if ((string) $string->attributes()->name == (string) $user_string->attributes()->name) {
                                 $translation_files_data[$file_name][$key] = stripslashes((string) $user_string);
                                 break;
                             } else {
                                 $translation_files_data[$file_name][$key] = null;
                             }
                         }
                     } else {
                         $translation_files_data[$file_name][$key] = null;
                     }
                 }
                 $i++;
             }
             $data["translation_files"] = $translation_files;
             $data["translation_files_data"] = $translation_files_data;
             $data["info"][$file_name] = $file["info"];
         }
     }
     return $data;
 }
コード例 #10
0
 public function forgotpasswordAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         try {
             if (empty($data['email'])) {
                 throw new Exception($this->_('Please enter your email address'));
             }
             $admin = new Admin_Model_Admin();
             $admin->findByEmail($data['email']);
             if (!$admin->getId()) {
                 throw new Exception($this->_("This 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();
             $data = array("success" => 1);
         } catch (Exception $e) {
             $data = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
コード例 #11
0
 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));
     }
 }
コード例 #12
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;
 }
コード例 #13
0
ファイル: Application.php プロジェクト: BeamlabsTigre/Webapp
 public function getShortTabbarMoreName()
 {
     return Core_Model_Lib_String::formatShortName($this->getTabbarMoreName());
 }
コード例 #14
0
ファイル: View.php プロジェクト: bklein01/SiberianCMS
 public function __call($method, $args)
 {
     $accessor = substr($method, 0, 3);
     $magicKeys = array('set', 'get', 'uns', 'has');
     if (in_array($accessor, $magicKeys)) {
         $key = Core_Model_Lib_String::camelize(substr($method, 3));
         $method = $accessor . 'Data';
         $value = isset($args[0]) ? $args[0] : null;
         return call_user_func(array($this, $method), $key, $value);
     }
     return parent::__call($method, $args);
 }
コード例 #15
0
ファイル: Facebook.php プロジェクト: bklein01/SiberianCMS
 protected function _prepareFbPost($post_datas)
 {
     $post = new Core_Model_Default();
     $icon_url = "https://graph.facebook.com/{$post_datas['from']['id']}/picture";
     $count_comments = isset($post_datas['comments']['data']) ? count($post_datas['comments']['data']) : 0;
     if ($count_comments == 25) {
         $count_comments = ' > ' . $count_comments;
     }
     $count_likes = isset($post_datas['likes']['data']) ? count($post_datas['likes']['data']) : 0;
     if ($count_likes == 25) {
         $count_likes = ' > ' . $count_likes;
     }
     $comments = array();
     if (!empty($post_datas['comments']['data']) && is_array($post_datas['comments']['data'])) {
         foreach ($post_datas['comments']['data'] as $comment) {
             $created_at = new Zend_Date($comment['created_time'], Zend_Date::ISO_8601, new Zend_Locale('en_US'));
             $comments[] = new Core_Model_Default(array('id' => $comment['id'], 'name' => $comment['from']['name'], 'message' => $comment['message'], 'picture' => "https://graph.facebook.com/{$comment['from']['id']}/picture", 'created_at' => $created_at->toString($this->_("MM/dd/y hh:mm a"))));
         }
     }
     $created_at = new Zend_Date($post_datas['created_time'], Zend_Date::ISO_8601, new Zend_Locale('en_US'));
     $message = '';
     if (!empty($post_datas['message'])) {
         $message = $post_datas['message'];
     } else {
         if (!empty($post_datas['story'])) {
             $message = $post_datas['story'];
         }
     }
     $picture = !empty($post_datas['picture']) ? $post_datas['picture'] : '';
     $picture = !empty($post_datas['object_id']) ? "https://graph.facebook.com/{$post_datas['object_id']}/picture?width=200" : $picture;
     $datas = array('id' => $post_datas['id'], 'author' => $post_datas['from']['name'], "avatar_url" => $icon_url, 'message' => $message, 'short_message' => strlen($message) > 300 ? Core_Model_Lib_String::truncate($message, 300) : $message, 'picture' => $picture, 'details' => !empty($post_datas['name']) ? $post_datas['name'] : '', "link" => isset($post_datas['link']) ? $post_datas['link'] : '', "created_at" => $created_at->toString($this->_("MM/dd/y hh:mm a")), "comments" => $comments, "nbr_of_comments" => $count_comments, "nbr_of_likes" => $count_likes);
     $post->setData($datas);
     return $post;
 }
コード例 #16
0
ファイル: Option.php プロジェクト: bklein01/siberian_cms_2
 public function getShortTabbarName()
 {
     $name = $this->getTabbarName();
     return Core_Model_Lib_String::formatShortName($name);
 }
コード例 #17
0
 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);
     }
 }