예제 #1
0
 /**
  * Busca todas as informações do usuário logado
  * @return array contendo nome de usuário, tipo e imagem de perfil do usuário logado
  */
 public function getUserLoggedInformation()
 {
     $this->session->start();
     $user = Users::findFirstByUser_id($this->session->get("user_id"));
     $user_name = explode(" ", $user->user_name);
     $vars['user'] = $user_name[0];
     $vars['user_type_id'] = $user->user_type_id;
     $vars['user_img'] = $user->user_img;
     return $vars;
 }
예제 #2
0
 /**
  * Carrega a tela inicial de configurações
  */
 public function indexAction()
 {
     $this->session->start();
     $user = Users::findFirstByUser_id($this->session->get("user_id"));
     if ($user->user_type_id <= 2) {
         $vars = $this->getUserLoggedInformation();
         //Busca informações da conta google
         $google_account = GoogleAccounts::findFirst();
         if (!empty($google_account)) {
             $vars['google_account_login'] = $google_account->google_account_login;
             $vars['google_account_key_file_name'] = $google_account->google_account_key_file_name;
             $vars['google_analytics_script'] = $google_account->google_analytics_script;
             $vars['google_analytics_active'] = $google_account->google_analytics_active;
             $vars['google_adsense_active'] = $google_account->google_adsense_active;
         }
         //Busca informações da página do facebook
         $fb_page = FacebookPages::findFirst();
         if ($fb_page != NULL) {
             $vars['fb_page_name'] = $fb_page->facebook_page_name;
             $vars['fb_active'] = $fb_page->facebook_active;
         }
         //Busca informações do twitter
         $tw_account = TwitterAccounts::findFirst();
         if (!empty($tw_account)) {
             $vars['tw_account_app_id'] = $tw_account->twitter_account_app_id;
             $vars['tw_account_app_secret'] = $tw_account->twitter_account_app_secret;
             $vars['tw_account_username'] = $tw_account->twitter_account_username;
             $vars['tw_active'] = $tw_account->twitter_active;
         }
         //Busca as preferências do blog
         $preferences = Blogs::findFirst();
         if (!empty($preferences)) {
             $vars['title'] = $preferences->blog_name;
             $vars['url'] = $preferences->blog_url;
             $vars['mail'] = $preferences->blog_mail;
             $vars['mail_active'] = $preferences->blog_send_mail;
             $vars['blog_about'] = $preferences->blog_about;
             $vars['menus'] = $this->getSideBarMenus();
         }
         //Caso haja dados de conta a ser exibido seta as váriaveis para exibição na view
         if (!empty($vars)) {
             $this->view->setVars($vars);
         }
         $this->view->render("settings", "index");
     } else {
         $this->response->redirect(URL_PROJECT . "admin");
     }
 }
예제 #3
0
 /**
  * Carrega tabela com uma lista dos plugins instalados
  */
 public function listPluginsAction()
 {
     $this->session->start();
     if ($this->session->get("user_id") != NULL) {
         $vars = $this->getUserLoggedInformation();
         $vars['menus'] = $this->getSideBarMenus();
         $usr = Users::findFirstByUser_id($this->session->get("user_id"));
         if ($usr->user_type_id <= 2) {
             $plugins = Plugin::find()->toArray();
             foreach ($plugins as $id => $plugin) {
                 $menus[$id] = Menu::findFirstByMenu_id($plugin['menu_id'])->toArray();
             }
             $vars['menu'] = $menus;
             $vars['plugins'] = $plugins;
         }
     }
     $this->view->setVars($vars);
 }
예제 #4
0
 /**
  * Carrega uma tabela listando as postagens existentes no sistema
  */
 public function listPostsAction()
 {
     $this->session->start();
     if ($this->session->get('user_id') != NULL) {
         $vars = $this->getUserLoggedInformation();
         $user = Users::findFirstByUser_id($this->session->get('user_id'));
         if ($user->user_type_id < 3) {
             $posts = Posts::find(array("order" => "post_date_posted DESC"));
         } elseif ($user->user_type_id == 3) {
             $usr = Users::find(array("conditions" => "user_type_id > :user_type_id: OR user_id = :user_id: ", "bind" => array("user_type_id" => $user->user_type_id, "user_id" => $user->user_id)));
             foreach ($usr as $u) {
                 $arr_id_users[] = $u->user_id;
             }
             $string_users = implode(",", $arr_id_users);
             $posts = Posts::find(array("conditions" => "post_author IN ({$string_users})", "order" => "post_date_posted DESC"));
         } else {
             $posts = Posts::findByPost_author($user->user_id);
         }
         $vars['menus'] = $this->getSideBarMenus();
         $vars['posts'] = $posts;
         $vars['categories'] = $this->getCategoriesByPost($posts);
         $this->view->setVars($vars);
         $this->view->render("post", "listPosts");
     } else {
         $this->response->redirect(URL_PROJECT . 'admin');
     }
 }
예제 #5
0
 /**
  * Altera o status de um usuário; Ativa se estiver desativado e desativa caso contrário
  * @param int $user_id id do usuário
  */
 public function ActiveOrdeactiveUser($user_id)
 {
     $user = Users::findFirstByUser_id($user_id);
     $user->user_active = !$user->user_active ? 1 : 0;
     $success = $user->save();
     return $success;
 }
예제 #6
0
 /**
  * Recebe um id de usuário via POST e deleta do banco de dados
  */
 public function deleteUserAction()
 {
     $this->view->disable();
     $user_id = intval($this->request->getPost('user_id'));
     $user_blog = UserBlog::findFirstByUser_id($user_id);
     $delete = !$user_blog ? true : $user_blog->delete();
     $user = Users::findFirstByUser_id($user_id);
     $data['success'] = $delete ? $user->delete() : $delete;
     echo json_encode($data);
 }