public function indexAction()
 {
     $_SESSION['list_page'] = "0";
     $facebookadmin = new Ishali_FacebookAdmin();
     $facebook = new Ishali_Facebook();
     $facebook->begins_works('1');
     $manage_pages = $facebookadmin->checkpermissions('manage_pages');
     if (!isset($this->_SESSION->iduseradmin)) {
         $link_login = APP_DOMAIN . "/admin/login";
         header("Location:{$link_login}");
     }
     if ($manage_pages) {
         $this->view->appid = $facebook->getAppId();
         $this->view->fbuserid = $facebook->getuserfbid();
         $this->view->list_pages = $facebookadmin->list_pages($this->view->fbuserid, 'page');
         //		$article = App_Models_ArticleModel::getInstance()->getDetail(1);
         //$time_start = microtime(true);
         $this->view->pageslist = App_Models_PagesModel::getInstance()->getList('a', 10, 1, $this->view->fbuserid);
         //        $time_end = microtime(true);
         //$time = $time_end - $time_start;
         //echo "Did nothing in $time seconds\n";
         //        $mausac = App_Models_BangmauModel::getInstance()->getList();
         //            echo "<pre>";
         //        print_r( $this->view->pageslist);
         //        echo "</pre>";
         ////        exit;
     } else {
         $facebookadmin->install();
     }
 }
 public function indexAction()
 {
     $facebookadmin = new Ishali_FacebookAdmin();
     $facebook = new Ishali_Facebook();
     $facebook->begins_works('1');
     $manage_pages = $facebookadmin->checkpermissions('manage_pages');
     if ($manage_pages) {
         $this->view->appid = $facebook->getAppId();
         $this->view->fbuserid = $facebook->getuserfbid();
         //		$this->view->list_pages = $facebookadmin->list_pages($this->view->fbuserid, 'page');
         $request = $this->getRequest();
         $this->view->curr_page = $request->getParam('search_page', 1);
         $this->view->count = 45;
         $result = App_Models_IshaliModel::getInstance()->getList($this->view->curr_page, $this->view->count);
         $this->view->total = $result['total'];
         @($this->view->pageslist = $result['data']);
         $paging = array();
         $paging['totalRecord'] = $result['total'];
         $paging['currentPage'] = $this->view->curr_page;
         $paging['numDisplay'] = 5;
         $paging['pageSize'] = $this->view->count;
         $paging['action'] = APP_DOMAIN . '/ishali';
         $this->view->paging = json_encode($paging);
     } else {
         $facebookadmin->install();
     }
 }
 public function indexAction()
 {
     $store = App_Models_StoreModel::getInstance();
     $id_page_add_tab = $this->_request->getParam("pg");
     $_SESSION['list_page'] = "0";
     $facebookadmin = new Ishali_FacebookAdmin();
     $facebook = new Ishali_Facebook();
     $facebook->begins_works('1', $id_page_add_tab);
     $manage_pages = $facebookadmin->checkpermissions('manage_pages');
     /*
     if(!isset($this->_SESSION->iduseradmin))
     		{
     			$link_login = APP_DOMAIN."/admin/login";
     			header("Location:$link_login");
     		}
     */
     //Cai App Vao Page
     if ($id_page_add_tab != "") {
         $iduser_fb = $facebook->getuserfbid();
         $user_page = $facebook->getuserpages();
         $status = 0;
         //echo '<pre>';print_r($user_page);exit;
         foreach ($user_page as $key => $value) {
             //echo $value['id'];exit;
             if ($id_page_add_tab == $value['id']) {
                 $status = 1;
             }
         }
         if ($status == 1) {
             $linkGraphPage = "http://graph.facebook.com/{$id_page_add_tab}";
             $info_page = $facebook->getGraphFB($linkGraphPage);
             $page_name = $info_page->name;
             $link_page = $info_page->link;
             if (!$store->checkManagerPage($id_page_add_tab, $iduser_fb)) {
                 $sql = "insert into ishali_pages(id_fb_page, page_name, id_fb, link_page) values('{$id_page_add_tab}', '{$page_name}', '{$iduser_fb}', '{$link_page}')";
                 $store->InsertDeleteUpdateQuery($sql);
             }
         }
     }
     if ($manage_pages) {
         $this->view->appid = $facebook->getAppId();
         $this->view->fbuserid = $facebook->getuserfbid();
         $this->view->list_pages = $facebookadmin->list_pages($this->view->fbuserid, 'page');
         $this->view->pageslist = App_Models_PagesModel::getInstance()->getList('a', 10, 1, $this->view->fbuserid);
     } else {
         $facebookadmin->install();
     }
 }
 public function indexAction()
 {
     $facebookadmin = new Ishali_FacebookAdmin();
     $facebook = new Ishali_Facebook();
     $facebook->begins_works('1');
     $manage_pages = $facebookadmin->checkpermissions('manage_pages');
     if (!isset($this->_SESSION->iduseradmin)) {
         $link_login = APP_DOMAIN . "/admin/login";
         header("Location:{$link_login}");
     }
     if ($manage_pages) {
         $this->view->appid = $facebook->getAppId();
         $this->view->fbuserid = $facebook->getuserfbid();
         $this->view->list_pages = $facebookadmin->list_pages($this->view->fbuserid, 'page');
         $this->view->pageslist = App_Models_PagesModel::getInstance()->getList2();
     } else {
         $facebookadmin->install();
     }
 }
 public function preDispatch()
 {
     $request = $this->getRequest();
     $facebook = new Ishali_Facebook();
     /*
     http://www.facebook.com/pages/HCM/448507661830693?sk=app_121397851394173&app_data=index/detail?id=109
     
     		$pagedata  = $facebook->getpagearr();
     		echo "<pre>";
     		print_r($pagedata['app_data']);
     		echo "</pre>";
     //exit;
     */
     if (isset($_GET['request_ids'])) {
         $ts = $_GET['request_ids'];
     } else {
         $ts = 0;
     }
     $facebook->begins_works($ts);
     $this->view->id_fb_page = $facebook->getpageid();
     $this->view->id_user = $facebook->getuserfbid();
     // TODO:
     //        $this->view->id_fb_page = 123453;
     //        $this->view->id_fb_page ='388347091211147';
     //        $this->view->id_user = 9999;
     /*
      * get page info
      */
     // exit;
     if ($this->view->id_fb_page <= 0) {
         $this->view->id_fb_page = $_SESSION['idpage'];
     } else {
         $_SESSION['idpage'] = $this->view->id_fb_page;
     }
     //         echo $_SESSION['idpage'];
     $page = new App_Entities_Pages();
     $page = App_Models_PagesModel::getInstance()->getDetail($this->view->id_fb_page);
     //        echo $page->an_hien;
     //        exit;
     //$this->_redirect('/home/index');
     if ($page->an_hien == 0) {
         //   $this->_redirect('/thongbao');
     }
     //         echo $page->templates;
     /*
      * init layout
      */
     /*End thiet lap nhan tin*/
     $fb = $facebook->getFB();
     if (isset($_GET['request_ids'])) {
         $reqId = $_GET['request_ids'];
         $requests = $fb->api('/me/apprequests/?request_ids=' . $reqId);
         $itemData = $requests['data'][0]['data'];
         //		 echo "<pre>";
         //		 print_r($requests);
         //		 echo "</pre>";
         //		 exit;
         if (isset($itemData) && $itemData != "") {
             echo "<script language='javascript'>top.location.href='" . $itemData . "'</script>";
             exit(0);
         } else {
             if (isset($requests['data'][1]['data']) && $requests['data'][1]['data'] != "") {
                 echo "<script language='javascript'>top.location.href='" . $requests['data'][1]['data'] . "'</script>";
                 exit(0);
             } else {
                 if (isset($requests['data'][2]['data']) && $requests['data'][2]['data'] != "") {
                     echo "<script language='javascript'>top.location.href='" . $requests['data'][2]['data'] . "'</script>";
                     exit(0);
                 }
             }
         }
     }
     /*End thiet lap nhan tin*/
     $option = array('layout' => 'layout', 'layoutPath' => LAYOUT_PATH . '/' . $page->templates);
     Zend_Layout::startMvc($option);
     /*
      * get menu
      */
     $listMenu = App_Models_ArticleModel::getInstance()->getListByFbPage($this->view->id_fb_page);
     /*
      * assign param
      */
     $this->view->page = $page;
     $this->view->appTitle = $page->page_name;
     $this->view->appFooter = $page->footer;
     $this->view->bodystyle = "font-size:{$page->font_size};";
     $this->view->bodystyle .= 'color:' . $page->color . ';';
     if ($page->background_images != null && $page->background_images != '') {
         $page_background = APP_DOMAIN . '/public/images/background_images/' . $page->background_images;
         $this->view->bodystyle .= 'background-image: url(' . $page_background . ');';
     } else {
         if ($page->background_color != null && $page->background_color != '') {
             $this->view->bodystyle .= 'background-color:' . $page->background_color . ';';
         }
     }
     $this->view->listMenu = $listMenu;
 }