private function _updateUserDb()
 {
     $fb_users = HTS_Util::getDbTable('users');
     $fb_user = $fb_users->findOneByIdSocial($this->_id_social);
     if (empty($fb_user)) {
         $user_profile = $this->_social->api('/me');
         if (FB_DEBUG) {
             Zend_Debug::dump($user_profile);
         }
         $fb_user = HTS_Util::getDbRow('users');
         $birthday = new Zend_Date(@$user_profile['Birthday'], 'dd/MM/yyyy');
         $updated_time = new Zend_Date(@$user_profile['Updated_time']);
         //TODO some values are null -> undefined index warning
         $fb_user->id_social = $user_profile['Id'];
         $fb_user->name = $user_profile['Name'];
         $fb_user->first_name = @$user_profile['First_name'];
         $fb_user->middle_name = @$user_profile['Middle_name'];
         $fb_user->last_name = @$user_profile['Last_name'];
         $fb_user->link = $user_profile['Link'];
         $fb_user->birthday = @$birthday->toString('yyyy/MM/dd');
         $fb_user->gender = $user_profile['Gender'];
         $fb_user->timezone = @$user_profile['Timezone'];
         $fb_user->locale = @$user_profile['Locale'];
         $fb_user->time_created = time();
         $fb_user->time_modified = time();
         $fb_user->time_social_modified = $updated_time->toValue();
         $this->_id_user = $fb_user->save();
     }
     $this->_user = $fb_user;
     $this->_id_user = $fb_user->id;
 }
 public function publishedPageAction()
 {
     echo '<pre>';
     var_dump('Facebook_FacebookController' . $this->_params);
     echo '</pre>';
     die;
     $survey = $this->_params['survey'];
     $survey_pages_db = HTS_Util::getDbTable('SurveyPages');
     $this->view->pages = $survey_pages_db->getAllByIdSurvey($survey['id']);
 }
 public function preDispatch()
 {
     parent::preDispatch();
     $this->_helper->layout()->setLayout('hts_canvas');
     $this->_page_list = $this->_social->getPageList();
     $this->_id_page = !empty($this->_params['id_page']) ? $this->_params['id_page'] : null;
     $this->_stores_table = HTS_Util::getDbTable('stores');
     $this->_initMenus($this->_params);
     $this->_extraValues();
 }
 public function init()
 {
     parent::init();
     $this->setName('add_rss');
     $this->setMethod('post');
     //get drop down list for autopost config
     $autopost_configs_db = HTS_Util::getDbTable("autopostconfigs");
     $autopost_configs = $autopost_configs_db->getList();
     $autopost_configs_drop_down = array();
     foreach ($autopost_configs as $config) {
         $autopost_configs_drop_down[$config["id"]] = $config["name"];
     }
     $id_category = new Zend_Form_Element_Select('id_category');
     $id_category->setLabel('CATEGORY');
     $new_category = new Zend_Form_Element_Text('new_category');
     $new_category->setLabel('');
     if (!empty($this->_params['id_category'])) {
         $new_category->setValue("");
     } else {
         $new_category->setValue($this->getTranslator()->translate('CATEGORY_GENERAL'));
     }
     $new_category->addValidator('StringLength', false, array('max' => 200, 'encoding' => 'UTF-8'));
     $title = new Zend_Form_Element_Text('title');
     $title->setLabel('TITLE');
     $title->addValidator('StringLength', false, array('max' => 200, 'encoding' => 'UTF-8'));
     $id_rss = new Zend_Form_Element_Hidden('id_rss');
     $link = new Zend_Form_Element_Text('link');
     $link->setLabel('RSS_URL')->setRequired(true)->addValidator('NotEmpty', true);
     $num_stories = new Zend_Form_Element_Text('num_stories');
     $num_stories->setLabel('NUM_OF_ITEMS')->setValue(5)->addValidator(new Zend_Validate_Digits())->addValidator(new Zend_Validate_Between(array('min' => 5, 'max' => 100)))->setRequired(true);
     $is_allow_comment = new Zend_Form_Element_Checkbox("is_allow_comment");
     $is_allow_comment->setLabel("Allow comment")->setCheckedValue(1)->setUncheckedValue(0)->setValue(1);
     $is_autopost = new Zend_Form_Element_Checkbox("is_autopost");
     $is_autopost->setLabel("Allow auto post")->setCheckedValue(1)->setUncheckedValue(0);
     $id_autopost_config = new Zend_Form_Element_Select("id_autopost_config");
     $id_autopost_config->setLabel("Frequency")->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'ERR_AUTO_POST_EMPTY')))->addMultiOptions($autopost_configs_drop_down);
     $max_news_post = new Zend_Form_Element_Text("max_news_post");
     $max_news_post->setLabel("Max news post")->setValue(5)->setRequired(true)->addValidator('lessThan', true, array('max' => 20, 'messages' => array(Zend_Validate_LessThan::NOT_LESS => 'ERR_MAX_NEW_POSTED_NOT_BETWEEN')));
     $this->addElements(array($id_rss, $link, $title, $id_category, $new_category, $num_stories, $is_allow_comment, $is_autopost, $id_autopost_config, $max_news_post));
     $this->setElementDecorators($this->_element_decorators);
     $id_rss->setDecorators($this->_hidden_decorators);
 }
 public function listAction()
 {
     $categories_db = HTS_Util::getDbTable('categories');
     $categories = $categories_db->getEnableByIdPage($this->_id_page);
     if (empty($this->_params['id_category'])) {
         if (isset($_COOKIE['id_' . $this->_id_page]) && $this->_checkValidCategory($_COOKIE['id_' . $this->_id_page], $categories)) {
             $this->_params['id_category'] = $_COOKIE['id_' . $this->_id_page];
         } else {
             $current_category = $this->_getFirstCategory($categories);
             if (!empty($current_category)) {
                 $this->_params['id_category'] = $current_category->id;
                 //TODO Zend_Cookie
                 setcookie('detail_source_' . $this->_id_page, "all", time() + 7 * 24 * 60 * 60, '/');
             }
         }
     } else {
         if ($this->_checkValidCategory($this->_params['id_category'], $categories)) {
             setcookie('id_' . $this->_id_page, $this->_params['id_category'], time() + 7 * 24 * 60 * 60, '/');
             setcookie('detail_source_' . $this->_id_page, "all", time() + 7 * 24 * 60 * 60, '/');
         } else {
             $current_category = $this->_getFirstCategory($categories);
             if (!empty($current_category)) {
                 $this->_params['id_category'] = $current_category->id;
                 //TODO Zend_Cookie
                 setcookie('detail_source_' . $this->_id_page, "all", time() + 7 * 24 * 60 * 60, '/');
             }
         }
     }
     if (!empty($this->_params['id_category'])) {
         $rss_db = HTS_Util::getDbTable('rss');
         $rss_list = $rss_db->getEnableByCategory($this->_params['id_category']);
         $this->view->rss_list = $rss_list;
         $this->view->feeds = $this->_orderRssNews($rss_list);
         $this->view->id_category = $this->_params['id_category'];
     }
     if ($this->_social->isPageAdmin()) {
         $this->view->owner = 'owner';
     }
     $this->view->id_page = $this->_id_page;
     $this->view->categories = $categories;
 }
 private function _updateUserDb()
 {
     $google_users = HTS_Util::getDbTable('users');
     $google_user = $google_users->findOneByIdSocial($this->_id_social);
     if (empty($google_user)) {
         $google_user = HTS_Util::getDbRow('users');
         $birthday = new Zend_Date(@$this->_me['birthday'], 'dd/MM/yyyy');
         //TODO some values are null -> undefined index warning
         $google_user->id_social = $this->_id_social;
         $google_user->name = $this->_me['displayName'];
         //			$google_user->first_name = $this->_me['name']['givenName'];
         //			$google_user->middle_name = @$this->_me['name']['middleName'];
         //			$google_user->last_name = @$this->_me['name']['familyName'];
         $google_user->link = $this->_me['url'];
         $google_user->image = $this->_me['image']['url'];
         $google_user->birthday = @$birthday->toString('yyyy/MM/dd');
         $google_user->gender = $this->_me['gender'];
         //$google_user->timezone = $this->_me['timezone'];
         $google_user->locale = @$this->_me['currentLocation'];
         $google_user->time_created = time();
         $google_user->time_modified = time();
         $this->_id_user = $google_user->save();
     }
     $this->_user = $google_user;
     $this->_id_user = $google_user->id;
 }
 protected function _updateUserDb()
 {
     $userData = HTS_Util::getObjectFileCache()->load('user_' . $this->_id_social);
     if ($userData === false) {
         $user_db = HTS_Util::getDbTable('users');
         $user = $user_db->findOneByIdSocial($this->_id_social);
         if (empty($user)) {
             $user_profile = $this->getUserProfile();
             $user = HTS_Util::getDbRow('users');
             //TODO some values are null -> undefined index warning
             if (!empty($user_profile['birthday'])) {
                 $birthday = new Zend_Date(@$user_profile['birthday'], 'dd/MM/yyyy');
                 $user->birthday = @$birthday->toString('yyyy/MM/dd');
             }
             $updated_time = new Zend_Date($user_profile['updated_time']);
             $user->id_social = $user_profile['id'];
             $user->name = $user_profile['name'];
             $user->email = @$user_profile['email'];
             $user->first_name = $user_profile['first_name'];
             $user->middle_name = @$user_profile['middle_name'];
             $user->last_name = @$user_profile['last_name'];
             $user->link = $user_profile['link'];
             $user->image = 'http://graph.facebook.com/' . $user_profile['id'] . '/picture';
             $user->gender = $user_profile['gender'];
             $user->timezone = $user_profile['timezone'];
             $user->locale = $user_profile['locale'];
             $user->time_created = time();
             $user->time_modified = time();
             $user->time_social_modified = $updated_time->toValue();
         }
         $user->save();
         HTS_Util::getObjectFileCache()->save($user->toArray(), 'user_' . $this->_id_social);
     } else {
         $user_db = HTS_Util::getDbTable('users');
         $user = $user_db->createRow($userData);
     }
     $this->_user = $user;
     $this->_id_user = $user->id;
 }