Ejemplo n.º 1
0
 public function __construct()
 {
     $this->view = ViewManager::getInstance();
     // get the current user and put it to the view
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     if (isset($_SESSION["currentuser"])) {
         $this->currentUser = new User(NULL, $_SESSION["currentuser"]);
         //add current user to the view, since some views require it
         $usermapper = new UserMapper();
         $this->tipo = $usermapper->buscarPorLogin($_SESSION["currentuser"]);
         /* print_r($this->tipo);
            die();*/
         $this->view->setVariable("tipo", $this->tipo);
         $this->view->setVariable("currentusername", $this->currentUser->getLogin());
     }
     if (isset($_SESSION["currentcod1"]) && isset($_SESSION["currentcod2"]) && isset($_SESSION["currentcod3"])) {
         $codigomapper1 = new CodigoMapper();
         $this->currentCod1 = $codigomapper1->buscarPinchoPorCodigo($_SESSION["currentcod1"]);
         $codigomapper2 = new CodigoMapper();
         $this->currentCod2 = $codigomapper2->buscarPinchoPorCodigo($_SESSION["currentcod2"]);
         $codigomapper3 = new CodigoMapper();
         $this->currentCod3 = $codigomapper3->buscarPinchoPorCodigo($_SESSION["currentcod3"]);
     }
 }
Ejemplo n.º 2
0
 /**
  * Sets a new View (object)
  *
  * @param string|View $view
  */
 public function setView($view)
 {
     $this->view = $view;
     // construct the view if needed
     if (!$this->view instanceof View) {
         $this->view = $this->viewManager->forge($this->view);
     }
 }
Ejemplo n.º 3
0
 public function __construct()
 {
     $this->view = ViewManager::getInstance();
     // get the current user and put it to the view
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     if (isset($_SESSION["currentuser"])) {
         $this->currentUser = new User($_SESSION["currentuser"]);
         //add current user to the view, since some views require it
         $this->view->setVariable("currentusername", $this->currentUser->getUsername());
     }
 }
Ejemplo n.º 4
0
 public static function getInstance()
 {
     if (self::$viewmanager_singleton == null) {
         self::$viewmanager_singleton = new ViewManager();
     }
     return self::$viewmanager_singleton;
 }
Ejemplo n.º 5
0
 /**
  * handle admin overview request
  */
 private function handleAdminOverview()
 {
     $view = ViewManager::getInstance();
     $log = Logger::getInstance();
     $logfile = $log->getLogFile();
     if ($view->isType(self::VIEW_FILE)) {
         $request = Request::getInstance();
         $extension = ".log";
         $filename = $request->getDomain() . $extension;
         header("Content-type: application/{$extension}");
         header("Content-Length: " . filesize($logfile));
         // stupid bastards of microsnob: ie does not like attachment option
         $browser = $request->getValue('HTTP_USER_AGENT', Request::SERVER);
         if (strstr($browser, 'MSIE')) {
             header("Content-Disposition: filename=\"{$filename}\"");
         } else {
             header("Content-Disposition: attachment; filename=\"{$filename}\"");
         }
         readfile($logfile);
         exit;
     } else {
         $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
         $template->setVariable('logfile', nl2br(file_get_contents($logfile)), false);
         $url = new Url(true);
         $url->setParameter($view->getUrlId(), self::VIEW_FILE);
         $template->setVariable('href_export', $url->getUrl(true), false);
         $this->template[$this->director->theme->getConfig()->main_tag] = $template;
     }
 }
Ejemplo n.º 6
0
 /**
  * Initialize Page Manager
  *
  * ## Overview
  *
  * @uses SatanBarbaraApp
  * @uses SessionManager
  * @uses ViewManager
  * @uses DebugManager
  * @uses RouteManager
  * @uses PageView
  *
  * @see RouteManager
  *
  * @param array An array of creds for SendGrid API.
  * @return true Always unless fatal error or exception is thrown.
  *
  * @version 2015-07-05.1
  * @since 0.5.1b
  * @author TronNet DevOps [Sean Murray] <*****@*****.**>
  */
 public static function Init($params)
 {
     DebugManager::Log("Initializing Page Manager", '@');
     DebugManager::Log($params);
     $appConfig = SatanBarbaraApp::GetConfig();
     /**
      * @todo have config in it's own 'config' position instead of array_merge
      */
     $data = array('app' => array_merge($appConfig[SATANBARBARA_CURRENT_ENVIRONMENT], array()), 'page' => $params);
     DebugManager::Log("checking if logged in...", null, 3);
     if (SessionManager::IsLoggedIn()) {
         $data['session'] = array('is_auth' => true, 'account' => SessionManager::GetAccount());
         DebugManager::Log("Got an account, checking for a saved program...", null, 3);
     }
     $Page = ucfirst($params['page']) . 'View';
     DebugManager::Log("Searching for view with class name: " . $Page);
     if ($Page::HasAccess(SessionManager::GetAccessLevel())) {
         $Page::Init($data);
         ViewManager::Render($Page);
     } else {
         DebugManager::Log("looks like this page requires auth but user isn't authenticated!");
         RouteManager::GoToPageURI('login');
     }
     return true;
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     $this->view = ViewManager::getInstance();
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     if (isset($_SESSION["currentuser"])) {
         $this->currentUser = $_SESSION["currentuser"];
         $this->view->setVariable("currentusername", $this->currentUser);
     }
 }
Ejemplo n.º 8
0
 public function __construct()
 {
     $this->view = ViewManager::getInstance();
     // get the current user and put it to the view
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     //inicializa la variable
     $this->friendDAO = new FriendDAO();
     if (isset($_SESSION["currentuser"])) {
         //En la sesion de currentuser se encuentra todo el usuario
         //ya que al hacer el login se introdujo todo el usuario en la sesion
         $this->currentUser = $_SESSION["currentuser"];
         $this->view->setVariable("currentusername", $this->currentUser);
         //consigue el numero total de solicitudes de amistad
         $numSolicitudes = $this->friendDAO->getNumSolicitudes($this->currentUser->getEmail());
         //Carga el num solicitudes en la vista
         $this->view->setVariable("numSolicitudes", $numSolicitudes);
     }
 }
Ejemplo n.º 9
0
 /**
  * Runs action
  * @return boolean
  */
 function run()
 {
     if (file_exists('actions/' . $this->sAction['action'] . '.php')) {
         require_once 'actions/' . $this->sAction['action'] . '.php';
     } else {
         ErrorProcessor::generateError('Action Not Found ;]');
         return false;
     }
     $name = explode('/', $this->sAction['action']);
     $action = new $name[1]();
     return ViewManager::makeView($action->perform(), $this->sAction);
 }
Ejemplo n.º 10
0
 /**
  * Handles data coming from a get request 
  * @param array HTTP request
  */
 public function handleHttpGetRequest()
 {
     $viewManager = ViewManager::getInstance();
     if ($viewManager->isType(ViewManager::OVERVIEW) && $this->director->isAdminSection()) {
         $viewManager->setType(ViewManager::ADMIN_OVERVIEW);
     }
     switch ($viewManager->getType()) {
         default:
             $this->handleAdminOverviewGet();
             break;
     }
 }
 public function control()
 {
     $config = Config::getInstance();
     $this->addToView('is_registration_open', $config->getValue('is_registration_open'));
     if (isset($_POST['Submit']) && $_POST['Submit'] == 'Send Reset') {
         $this->disableCaching();
         $dao = DAOFactory::getDAO('OwnerDAO');
         $user = $dao->getByEmail($_POST['email']);
         if (isset($user)) {
             $token = $user->setPasswordRecoveryToken();
             $es = new ViewManager();
             $es->caching = false;
             $es->assign('apptitle', $config->getValue('app_title_prefix') . "ThinkUp");
             $es->assign('recovery_url', "session/reset.php?token={$token}");
             $es->assign('application_url', Utils::getApplicationURL($false));
             $es->assign('site_root_path', $config->getValue('site_root_path'));
             $message = $es->fetch('_email.forgotpassword.tpl');
             Mailer::mail($_POST['email'], $config->getValue('app_title_prefix') . "ThinkUp Password Recovery", $message);
             $this->addSuccessMessage('Password recovery information has been sent to your email address.');
         } else {
             $this->addErrorMessage('Error: account does not exist.');
         }
     }
     $this->view_mgr->addHelp('forgot', 'userguide/accounts/index');
     $this->setViewTemplate('session.forgot.tpl');
     return $this->generateView();
 }
 public function control()
 {
     $this->redirectToSternIndiaEndpoint('forgot.php');
     $config = Config::getInstance();
     //$this->addToView('is_registration_open', $config->getValue('is_registration_open'));
     // if (isset($_POST['email']) && $_POST['Submit'] == 'Send Reset') {
     // /$_POST['email'] = '*****@*****.**';
     if (isset($_POST['email'])) {
         $this->disableCaching();
         $dao = DAOFactory::getDAO('UserDAO');
         $user = $dao->getByEmail($_POST['email']);
         if (isset($user)) {
             $token = $user->setPasswordRecoveryToken();
             $es = new ViewManager();
             $es->caching = false;
             //$es->assign('apptitle', $config->getValue('app_title_prefix')."ThinkUp" );
             $es->assign('first_name', $user->first_name);
             $es->assign('recovery_url', "session/reset.php?token={$token}");
             $es->assign('application_url', Utils::getApplicationURL(false));
             $es->assign('site_root_path', $config->getValue('site_root_path'));
             $message = $es->fetch('_email.forgotpassword.tpl');
             $subject = $config->getValue('app_title_prefix') . "Stern India Password Recovery";
             //Will put the things in queue to mail the things.
             Resque::enqueue('user_mail', 'Mailer', array($_POST['email'], $subject, $message));
             $this->addToView('link_sent', true);
         } else {
             $this->addErrorMessage('Error: account does not exist.');
         }
     }
     $this->setViewTemplate('Session/forgot.tpl');
     return $this->generateView();
 }
Ejemplo n.º 13
0
 /**
  * @return str Object definition
  */
 public function makeModel()
 {
     //show full columns from table;
     $columns = array();
     try {
         $stmt = self::$pdo->query('SHOW FULL COLUMNS FROM ' . $this->table_name);
         while ($row = $stmt->fetch()) {
             $row['PHPType'] = $this->converMySQLTypeToPHP($row['Type']);
             $columns[$row['Field']] = $row;
         }
     } catch (Exception $e) {
         throw new Exception('Unable to show columns from "' . $this->table_name . '" - ' . $e->getMessage());
     }
     //instantiate Smarty, assign results to view
     $view_mgr = new ViewManager();
     $view_mgr->assign('fields', $columns);
     $view_mgr->assign('object_name', $this->object_name);
     //$view_mgr->assign('parent_name', $this->parent_name);
     $tpl_file = EFC_ROOT_PATH . 'makemodel/view/model_object.tpl';
     //output results
     $results = $view_mgr->fetch($tpl_file);
     return $results;
 }
Ejemplo n.º 14
0
 private function handleExtensionPost()
 {
     $request = Request::getInstance();
     $template = new TemplateEngine();
     $view = ViewManager::getInstance();
     $this->renderExtension = true;
     if (!$request->exists('ext_id')) {
         throw new Exception('Extension ontbreekt.');
     }
     $id = intval($request->getValue('ext_id'));
     $template->setVariable('ext_id', $id, false);
     $url = new Url(true);
     $url_back = clone $url;
     $url_back->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
     $url_back->clearParameter('ext_id');
     $extension = $this->director->extensionManager->getExtensionFromId(array('id' => $id));
     $extension->setReferer($this);
     $this->director->theme->handleAdminLinks($template, $this->getName(array('id' => $id)), $url_detail);
     $extension->handleHttpPostRequest();
 }
Ejemplo n.º 15
0
 public function _updateTmpProducts($array_product, $key)
 {
     $view_manager = new ViewManager();
     $result = $view_manager->_getSqlChangedProducts($array_product, $key);
     $connection = connectionServer();
     foreach ($result as $sql) {
         $res = null;
         $res = mysql_query($sql, $connection);
         if ($res) {
         } else {
             $errno = mysql_errno($connection);
             $error = mysql_error($connection);
             switch ($errno) {
                 case 1062:
                     throw new HandleOperationsException($error);
                     break;
                 default:
                     throw new HandleOperationsException($error);
                     break;
             }
         }
     }
     closeConnectionServer($connection);
 }
Ejemplo n.º 16
0
 /**
  * Add informational message to view
  * Include field if the message goes on a specific place on the page; otherwise leave it null for the message
  * to be page-level.
  * @param str $msg
  * @param str $field Defaults to null for page-level messages.
  * @param bool $disable_xss Disable HTML encoding tags, defaults to false
  */
 public function addInfoMessage($msg, $field = null, $disable_xss = false)
 {
     $this->disableCaching();
     $this->view_mgr->addInfoMessage($msg, $field, $disable_xss);
 }
 /**
  * Send out insight email digest for a given time period.
  * @param Owner $owner Owner to send for
  * @param str $start When to start insight lookup
  * @param str $template Email view template to use
  * @param array $options Plugin options
  * return bool Whether email was sent
  */
 private function sendDigestSinceWithTemplate($owner, $start, $template, &$options)
 {
     $insights_dao = DAOFactory::GetDAO('InsightDAO');
     $start_time = date('Y-m-d H:i:s', strtotime($start, $this->current_timestamp));
     $insights = $insights_dao->getAllOwnerInstanceInsightsSince($owner->id, $start_time);
     if (count($insights) == 0) {
         return false;
     }
     $config = Config::getInstance();
     $view = new ViewManager();
     $view->caching = false;
     // If we've got a Mandrill key and template, send HTML
     if ($config->getValue('mandrill_api_key') != null && !empty($options['mandrill_template'])) {
         $view->assign('insights', $insights);
         $insights = $view->fetch(Utils::getPluginViewDirectory($this->folder_name) . '_email.insights_html.tpl');
         $parameters = array();
         $parameters['insights'] = $insights;
         $parameters['app_title'] = $config->getValue('app_title_prefix') . "ThinkUp";
         $parameters['app_url'] = Utils::getApplicationURL();
         $parameters['unsub_url'] = Utils::getApplicationURL() . 'account/index.php?m=manage#instances';
         // It's a weekly digest if we're going back more than a day or two.
         $days_ago = ($this->current_timestamp - strtotime($start)) / (60 * 60 * 24);
         $parameters['weekly_or_daily'] = $days_ago > 2 ? 'Weekly' : 'Daily';
         try {
             Mailer::mailHTMLViaMandrillTemplate($owner->email, 'ThinkUp has new insights for you!', $options['mandrill_template']->option_value, $parameters);
             return true;
         } catch (Mandrill_Unknown_Template $e) {
             // In this case, we'll fall back to plain text sending and warn the user in the log
             $logger = Logger::getInstance();
             $logger->logUserError("Invalid mandrill template configured:" . $options['mandrill_template']->option_value . ".", __METHOD__ . ',' . __LINE__);
             unset($options['mandrill_template']);
         }
     }
     $view->assign('apptitle', $config->getValue('app_title_prefix') . "ThinkUp");
     $view->assign('application_url', Utils::getApplicationURL());
     $view->assign('insights', $insights);
     $message = $view->fetch(Utils::getPluginViewDirectory($this->folder_name) . $template);
     list($subject, $message) = explode("\n", $message, 2);
     Mailer::mail($owner->email, $subject, $message);
     return true;
 }
Ejemplo n.º 18
0
 /**
  * handle user
  */
 private function handleUserGet($retrieveFields = true)
 {
     $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
     $request = Request::getInstance();
     if (!$request->exists('id')) {
         throw new Exception('User group is missing.');
     }
     $id = intval($request->getValue('id'));
     $template->setVariable('id', $id, false);
     $key = array('id' => $id);
     $user = $this->director->adminManager->getPlugin('User');
     $usr_used = $request->getValue('usr_used');
     if ($retrieveFields) {
         $searchcriteria = array('grp_id' => $id);
         $tmp = $user->getList($searchcriteria);
         $usr_used = $tmp['data'];
     }
     $search_used = $usr_used ? array('id' => $usr_used) : NULL;
     $search_free = $usr_used ? array('no_id' => $usr_used) : NULL;
     $user_used = $usr_used ? $user->getList($search_used) : array('data' => '');
     $user_free = $user->getList($search_free);
     $template->setVariable('cbo_usr_used', Utils::getHtmlCombo($user_used['data'], NULL, NULL, 'id', 'formatName'));
     $template->setVariable('cbo_usr_free', Utils::getHtmlCombo($user_free['data'], NULL, NULL, 'id', 'formatName'));
     $view = ViewManager::getInstance();
     $url = new Url(true);
     $breadcrumb = array('name' => $view->getName(), 'path' => $url->getUrl(true));
     $this->director->theme->addBreadcrumb($breadcrumb);
     $url->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
     $template->setVariable('href_back', $url->getUrl(true), false);
     $template->setVariable('title', $this->getName($key), false);
     $this->template[$this->director->theme->getConfig()->main_tag] = $template;
 }
 /**
  * Get fully-rendered HTML markup for this insight.
  * @param  Insight $insight Test insight to render in HTML.
  * @return str Insight HTML with this insight
  */
 protected function getRenderedInsightInHTML(Insight $insight)
 {
     if ($insight->related_data !== null && is_string($insight->related_data)) {
         $insight->related_data = Serializer::unserializeString($insight->related_data);
     }
     $view = new ViewManager();
     $view->caching = false;
     $view->assign('insights', array($insight));
     $view->assign('expand', true);
     $view->assign('tpl_path', THINKUP_WEBAPP_PATH . 'plugins/insightsgenerator/view/');
     $view->assign('enable_bootstrap', true);
     $view->assign('thinkup_application_url', Utils::getApplicationURL());
     $view->assign('site_root_path', 'https://thinkup.thinkup.com/');
     $html_insight = $view->fetch(THINKUP_WEBAPP_PATH . '_lib/view/insights.tpl');
     return $html_insight;
 }
 /**
  * Generates a one time upgrade token, and emails admins with the token info.
  */
 public static function generateUpgradeToken()
 {
     $token_file = FileDataManager::getDataPath('.htupgrade_token');
     $md5_token = '';
     if (!file_exists($token_file)) {
         $fp = fopen($token_file, 'w');
         if ($fp) {
             $token = self::TOKEN_KEY . rand(0, time());
             $md5_token = md5($token);
             if (!fwrite($fp, $md5_token)) {
                 throw new OpenFileException("Unable to write upgrade token file: " + $token_file);
             }
             fclose($fp);
         } else {
             throw new OpenFileException("Unable to create upgrade token file: " + $token_file);
         }
         // email our admin with this token.
         $owner_dao = DAOFactory::getDAO('OwnerDAO');
         $admins = $owner_dao->getAdmins();
         if ($admins) {
             $tos = array();
             foreach ($admins as $admin) {
                 $tos[] = $admin->email;
             }
             $to = join(',', $tos);
             $upgrade_email = new ViewManager();
             $upgrade_email->caching = false;
             $upgrade_email->assign('application_url', Utils::getApplicationURL(false));
             $upgrade_email->assign('token', $md5_token);
             $message = $upgrade_email->fetch('_email.upgradetoken.tpl');
             $config = Config::getInstance();
             Mailer::mail($to, "Upgrade Your ThinkUp Database", $message);
         }
     }
 }
 /**
  * Generates plugin page options markup - Calls parent::generateView()
  *
  * @return str view markup
  */
 protected function generateView()
 {
     // if we have some p[lugin option elements defined
     // render them and add to the parent view...
     if (count($this->option_elements) > 0) {
         $this->setValues();
         $view_mgr = new ViewManager();
         $view_mgr->disableCaching();
         // assign data
         $view_mgr->assign('option_elements', $this->option_elements);
         $view_mgr->assign('option_elements_json', json_encode($this->option_elements));
         $view_mgr->assign('option_headers', $this->option_headers);
         $view_mgr->assign('option_not_required', $this->option_not_required);
         $view_mgr->assign('option_not_required_json', json_encode($this->option_not_required));
         $view_mgr->assign('option_required_message', $this->option_required_message);
         $view_mgr->assign('option_required_message_json', json_encode($this->option_required_message));
         $view_mgr->assign('option_select_multiple', $this->option_select_multiple);
         $view_mgr->assign('option_select_visible', $this->option_select_visible);
         $view_mgr->assign('plugin_id', $this->plugin_id);
         $view_mgr->assign('user_is_admin', $this->isAdmin());
         $options_markup = '';
         if ($this->profiler_enabled) {
             $view_start_time = microtime(true);
             $options_markup = $view_mgr->fetch(self::OPTIONS_TEMPLATE);
             $view_end_time = microtime(true);
             $total_time = $view_end_time - $view_start_time;
             $profiler = Profiler::getInstance();
             $profiler->add($total_time, "Rendered view (not cached)", false);
         } else {
             $options_markup = $view_mgr->fetch(self::OPTIONS_TEMPLATE);
         }
         $this->addToView('options_markup', $options_markup);
     }
     return parent::generateView();
 }
Ejemplo n.º 22
0
 /**
  * Manages form output rendering
  * @param string Smarty template object
  * @see GuiProvider::renderForm
  */
 public function renderForm($theme)
 {
     $view = ViewManager::getInstance();
     $template = $theme->getTemplate();
     $template->setVariable($view->getUrlId(), $view->getName(), false);
     foreach ($this->template as $key => $value) {
         $template->setVariable($key, $value, false);
     }
 }
Ejemplo n.º 23
0
    /**
     * handle config
     */
    private function handleConfigGet($retrieveFields = true)
    {
        $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
        $request = Request::getInstance();
        if (!$request->exists('id')) {
            throw new Exception('Thema ontbreekt.');
        }
        $id = intval($request->getValue('id'));
        $template->setVariable('id', $id, false);
        $key = array('id' => $id);
        $themedetail = $this->getDetail($key);
        $theme = $this->director->themeManager->getThemeFromId($key);
        if ($retrieveFields) {
            $fileTpl = file_get_contents($theme->getTemplateFile());
            $fileIni = file_get_contents($theme->getConfigFile());
            $fileCss = file_get_contents($theme->getStyleSheetFile());
        } else {
            $fileTpl = $request->getValue('file_tpl');
            $fileIni = $request->getValue('file_ini');
            $fileCss = $request->getValue('file_css');
        }
        $template->setVariable('file_tpl', $fileTpl, false);
        $template->setVariable('file_ini', $fileIni, false);
        $template->setVariable('file_css', $fileCss, false);
        $theme = $this->director->theme;
        $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/editarea/edit_area/edit_area_full.js"></script>');
        $theme->addHeader('<script type="text/javascript">
editAreaLoader.init({ 	id: "area1", 
							start_highlight: true, 
							allow_toggle: true, 
							allow_resize: true,
							language: "en", 
							syntax: "php", 
							syntax_selection_allow: "css,html,js,php", 
					});

editAreaLoader.init({ 	id: "area2", 
							start_highlight: true, 
							allow_toggle: true, 
							allow_resize: true,
							language: "en", 
							syntax: "html", 
							syntax_selection_allow: "css,html,js,php", 
					});

editAreaLoader.init({ 	id: "area3", 
							start_highlight: true, 
							allow_toggle: true, 
							allow_resize: true,
							language: "en", 
							syntax: "css", 
							syntax_selection_allow: "css,html,js,php", 
					});
</script>');
        $template->setVariable('templateVars', $theme->getTemplateVars(), false);
        $view = ViewManager::getInstance();
        $url = new Url(true);
        $url_back = clone $url;
        $url_back->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW);
        $template->setVariable('href_back', $url_back->getUrl(true), false);
        $theme->addBreadcrumb(array('name' => $themedetail['name'], 'path' => $url_back->getUrl(true)));
        $theme->addBreadcrumb(array('name' => $view->getName(), 'path' => $url->getUrl(true)));
        $this->template[$this->director->theme->getConfig()->main_tag] = $template;
    }
Ejemplo n.º 24
0
 /**
  * handle navigation for sub classes / pages
  */
 public function handleAdminSubLinks($keyName, $title, $addBreadcrumb = false)
 {
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $template = new TemplateEngine();
     if (!$request->exists('nl_id')) {
         return;
     }
     $nl_id = $request->getValue('nl_id');
     $newsLetterName = $this->getName(array('id' => $nl_id));
     $template->setVariable('pageTitle', $newsLetterName, false);
     $tree_id = $request->getValue('tree_id');
     $tag = $request->getValue('tag');
     $template->setVariable('tree_id', $tree_id, false);
     $template->setVariable('tag', $tag, false);
     $template->setVariable('nl_id', $nl_id, false);
     if (!$addBreadcrumb) {
         return;
     }
     $url = new Url(true);
     $url->setParameter('tree_id', $tree_id);
     $url->setParameter('tag', $tag);
     $url->setParameter('id', $nl_id);
     $url->setParameter($view->getUrlId(), ViewManager::TREE_EDIT);
     $breadcrumb = array('name' => $newsLetterName, 'path' => $url->getUrl(true));
     $this->addBreadcrumb($breadcrumb);
 }
Ejemplo n.º 25
0
 /**
  * Send user email alert about invalid OAuth tokens, at most one message per week.
  * In test mode, this will only write the message body to a file in the application data directory.
  * @param str $email
  * @param str $username
  * @return bool Whether or not email was sent
  */
 private function sendInvalidOAuthEmailAlert($email, $username)
 {
     //Determine whether or not an email about invalid tokens was sent in the past 7 days
     $should_send_email = true;
     $option_dao = DAOFactory::getDAO('OptionDAO');
     $plugin_dao = DAOFactory::getDAO('PluginDAO');
     $plugin_id = $plugin_dao->getPluginId('facebook');
     $last_email_timestamp = $option_dao->getOptionByName(OptionDAO::PLUGIN_OPTIONS . '-' . $plugin_id, 'invalid_oauth_email_sent_timestamp');
     if (isset($last_email_timestamp)) {
         //option exists, a message was sent
         //a message was sent in the past week
         if ($last_email_timestamp->option_value > strtotime('-1 week')) {
             $should_send_email = false;
         } else {
             $option_dao->updateOption($last_email_timestamp->option_id, time());
         }
     } else {
         $option_dao->insertOption(OptionDAO::PLUGIN_OPTIONS . '-' . $plugin_id, 'invalid_oauth_email_sent_timestamp', time());
     }
     if ($should_send_email) {
         $mailer_view_mgr = new ViewManager();
         $mailer_view_mgr->caching = false;
         $mailer_view_mgr->assign('thinkup_site_url', Utils::getApplicationURL());
         $mailer_view_mgr->assign('email', $email);
         $mailer_view_mgr->assign('faceboook_user_name', $username);
         $message = $mailer_view_mgr->fetch(Utils::getPluginViewDirectory('facebook') . '_email.invalidtoken.tpl');
         Mailer::mail($email, "Please re-authorize ThinkUp to access " . $username . " on Facebook", $message);
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 26
0
 public function __construct(\ViewManager $view, $code = 200, $headers = array())
 {
     $headers["Content-type"] = "text/html";
     parent::__construct($view->render(true), $code, $headers);
 }
Ejemplo n.º 27
0
 public function control()
 {
     if ($this->isLoggedIn()) {
         $controller = new DashboardController(true);
         return $controller->go();
     } else {
         // register form validation
         $this->addHeaderCSS('assets/css/validate_password.css');
         $this->addHeaderJavaScript('assets/js/jquery.validate.min.js');
         $this->addHeaderJavaScript('assets/js/jquery.validate.password.js');
         $this->addHeaderJavaScript('assets/js/validate_password.js');
         $config = Config::getInstance();
         $is_registration_open = $config->getValue('is_registration_open');
         $this->disableCaching();
         $invite_dao = DAOFactory::getDAO('InviteDAO');
         if (isset($_GET['code'])) {
             $invite_code = $_GET['code'];
         } else {
             $invite_code = null;
         }
         $this->addToView('invite_code', $invite_code);
         $is_invite_code_valid = $invite_dao->isInviteValid($invite_code);
         if ($invite_code != null && $is_invite_code_valid) {
             $this->addSuccessMessage("Welcome, VIP! You've been invited to register on " . $config->getValue('app_title_prefix') . "ThinkUp.");
         }
         $has_been_registered = false;
         if (!$is_registration_open && !$is_invite_code_valid) {
             $this->addToView('closed', true);
             $disable_xss = true;
             $this->addErrorMessage('<p>Sorry, registration is closed on this installation of ' . $config->getValue('app_title_prefix') . "ThinkUp.</p>" . '<p><a href="http://thinkupapp.com">Install ThinkUp on your own server.</a></p>', null, $disable_xss);
         } else {
             $owner_dao = DAOFactory::getDAO('OwnerDAO');
             $this->addToView('closed', false);
             $captcha = new Captcha();
             if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') {
                 foreach ($this->REQUIRED_PARAMS as $param) {
                     if (!isset($_POST[$param]) || $_POST[$param] == '') {
                         $this->addErrorMessage('Please fill out all required fields.');
                         $this->is_missing_param = true;
                     }
                 }
                 if (!$this->is_missing_param) {
                     $valid_input = true;
                     if (!Utils::validateEmail($_POST['email'])) {
                         $this->addErrorMessage("Incorrect email. Please enter valid email address.", 'email');
                         $valid_input = false;
                     }
                     if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) {
                         $this->addErrorMessage("Passwords do not match.", 'password');
                         $valid_input = false;
                     } else {
                         if (!preg_match("/(?=.{8,})(?=.*[a-zA-Z])(?=.*[0-9])/", $_POST['pass1'])) {
                             $this->addErrorMessage("Password must be at least 8 characters and contain both numbers " . "and letters.", 'password');
                             $valid_input = false;
                         }
                     }
                     if (!$captcha->doesTextMatchImage()) {
                         $this->addErrorMessage("Entered text didn't match the image. Please try again.", 'captcha');
                         $valid_input = false;
                     }
                     if ($valid_input) {
                         if ($owner_dao->doesOwnerExist($_POST['email'])) {
                             $this->addErrorMessage("User account already exists.", 'email');
                         } else {
                             // Insert the details into the database
                             $activation_code = $owner_dao->create($_POST['email'], $_POST['pass2'], $_POST['full_name']);
                             if ($activation_code != false) {
                                 $es = new ViewManager();
                                 $es->caching = false;
                                 $es->assign('application_url', Utils::getApplicationURL(false));
                                 $es->assign('email', urlencode($_POST['email']));
                                 $es->assign('activ_code', $activation_code);
                                 $message = $es->fetch('_email.registration.tpl');
                                 Mailer::mail($_POST['email'], "Activate Your Account on " . $config->getValue('app_title_prefix') . "ThinkUp", $message);
                                 SessionCache::unsetKey('ckey');
                                 $this->addSuccessMessage("Success! Check your email for an activation link.");
                                 //delete invite code
                                 if ($is_invite_code_valid) {
                                     $invite_dao->deleteInviteCode($invite_code);
                                 }
                                 $has_been_registered = true;
                             } else {
                                 $this->addErrorMessage("Unable to register a new user. Please try again.");
                             }
                         }
                     }
                 }
                 if (isset($_POST["full_name"])) {
                     $this->addToView('name', $_POST["full_name"]);
                 }
                 if (isset($_POST["email"])) {
                     $this->addToView('mail', $_POST["email"]);
                 }
                 $this->addToView('has_been_registered', $has_been_registered);
             }
             $challenge = $captcha->generate();
             $this->addToView('captcha', $challenge);
         }
         $this->view_mgr->addHelp('register', 'userguide/accounts/index');
         return $this->generateView();
     }
 }
Ejemplo n.º 28
0
 /**
  * handle optin confirm
  */
 private function handleOptin()
 {
     $taglist = $this->getTagList();
     if (!$taglist) {
         return;
     }
     $request = Request::getInstance();
     $view = ViewManager::getInstance();
     $objUser = $this->getObject(self::TYPE_USER);
     $objSettings = $this->getObject(self::TYPE_SETTINGS);
     try {
         if (!$request->exists('key')) {
             throw new Exception('Parameter does not exist.');
         }
         $keyValue = $request->getValue('key');
         if (!$keyValue) {
             throw new Exception('Parameter is empty.');
         }
         $key = array('optin' => $keyValue);
         $objUser->enable($key);
         // retrieve settings to get redirect location
         $searchcriteria = array();
         foreach ($taglist as $item) {
             $searchcriteria = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
         }
         $settings = $objSettings->getSettings($searchcriteria['tree_id'], $searchcriteria['tag']);
         $location = $settings['optin_tree_id'] ? $this->director->tree->getPath($settings['optin_tree_id']) : '/';
         header("Location: {$location}");
         exit;
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('newsLetterErrorMessage', $e->getMessage(), false);
         $this->log->info($e->getMessage());
         $view->setType(ViewManager::OVERVIEW);
         $this->handleHttpGetRequest();
     }
 }
Ejemplo n.º 29
0


<?php 
include "includesCSS/includeCss.html";
//file: view/posts/view.php
require_once __DIR__ . "/../../core/ViewManager.php";
$view = ViewManager::getInstance();
$premios = $view->getVariable("premios");
$currentuser = $view->getVariable("currentusername");
$view->setVariable("nombre", "View Premio");
include "view/users/menuSuperior.php";
?>


<section class="gallery                                                                                                                                                                              " id="gallery">
		<div class="container">
			<div class="heading text-center">
				<img class="dividerline" src="archivos/sep.png" alt="">
				<h2>Premios 2015</h2>
				<img class="dividerline" src="archivos/sep.png" alt="">
			</div>
			
			<div id="grid-gallery" class="grid-gallery">
					<section class="grid-wrap">
						<ul  class="grid">
						 <li class="grid-sizer "></li><!-- for Masonry column width -->	
	<!--inicio -->		<?php 
foreach ($premios as $premio) {
    ?>
							<li class=" col-md-3">
 /**
  * Runs registered plugins' crawl function.
  *
  * About crawler exclusivity (mutex usage):
  * When launched by an admin, no other user, admin or not, will be able to launch a crawl until this one is done.
  * When launched by a non-admin, we first check that no admin run is under way, and if that's the case,
  * we launch a crawl for the current user only.
  * No user will be able to launch two crawls in parallel, but different non-admin users crawls can run in parallel.
  * @throws UnauthorizedUserException If user is not logged in
  * @throws CrawlerLockedException If a crawl is already in progress
  * @throws InstallerException If ThinkUp is in the midst of a database upgrade
  */
 public function runRegisteredPluginsCrawl()
 {
     if (!Session::isLoggedIn()) {
         throw new UnauthorizedUserException('You need a valid session to launch the crawler.');
     }
     $mutex_dao = DAOFactory::getDAO('MutexDAO');
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
     if (empty($owner)) {
         throw new UnauthorizedUserException('You need a valid session to launch the crawler.');
     }
     // are we in an upgrading state
     if (UpgradeDatabaseController::isUpgrading(true, 'Crawler')) {
         throw new InstallerException("ThinkUp needs a database migration, so we are unable to run the crawler.");
     }
     $global_mutex_name = self::GLOBAL_MUTEX;
     // Everyone needs to check the global mutex
     $lock_successful = 1;
     $mutex_dao->getMutex($global_mutex_name);
     // 1
     if ($lock_successful) {
         // Global mutex was free, which means no admin crawls are under way
         if ($owner->is_admin) {
             // Nothing more needs to be done, since admins use the global mutex
             $mutex_name = $global_mutex_name;
         } else {
             // User is a non-admin; let's use a user mutex.
             $mutex_name = 'crawler-' . $owner->id;
             $lock_successful = $mutex_dao->getMutex($mutex_name);
             $mutex_dao->releaseMutex($global_mutex_name);
         }
     }
     if ($lock_successful) {
         $this->emitObjectFunction('crawl');
         $mutex_dao->releaseMutex($mutex_name);
         //clear cache so that insight stream updates
         $v_mgr = new ViewManager();
         $v_mgr->clear_all_cache();
     } else {
         throw new CrawlerLockedException("Error starting crawler; another crawl is already in progress.");
     }
 }