private function __construct()
 {
     $this->appSchemaMap = array();
     $this->appNamespaceUriMap = array();
     $this->appContextRootMap = array();
     $config = Config::getInstance();
     foreach ($config->getSection('db') as $propertyId => $value) {
         $prefix = 'schema-for-app.';
         if (strpos($propertyId, $prefix) === 0) {
             $this->appSchemaMap[substr($propertyId, strlen($prefix))] = new Schema($value);
         }
     }
     foreach ($config->getSection('xml') as $propertyId => $value) {
         $prefix = 'namespaceUri-for-app.';
         if (strpos($propertyId, $prefix) === 0) {
             $this->appNamespaceUriMap[substr($propertyId, strlen($prefix))] = $value;
         }
     }
     foreach ($config->getSection('url') as $propertyId => $value) {
         $prefix = 'context-root-for-app.';
         if (strpos($propertyId, $prefix) === 0) {
             $this->appContextRootMap[substr($propertyId, strlen($prefix))] = $value;
         }
     }
 }
Пример #2
0
 /**
  * Check the $_POST'ed CAPTCHA inputs match the contents of the CAPTCHA.
  * @return bool
  */
 public function doesTextMatchImage()
 {
     //if in test mode, assume check is good if user_code is set to 123456
     if (Utils::isTest()) {
         if (isset($_POST['user_code']) && $_POST['user_code'] == '123456') {
             return true;
         } else {
             return false;
         }
     }
     switch ($this->type) {
         case self::RECAPTCHA_CAPTCHA:
             $config = Config::getInstance();
             $priv_key = $config->getValue('recaptcha_private_key');
             $resp = recaptcha_check_answer($priv_key, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
             if (!$resp->is_valid) {
                 return false;
             } else {
                 return true;
             }
             break;
         default:
             if (strcmp(md5($_POST['user_code']), SessionCache::get('ckey'))) {
                 return false;
             } else {
                 return true;
             }
             break;
     }
 }
Пример #3
0
 public function setUp()
 {
     parent::setUp();
     $webapp_plugin_registrar = PluginRegistrarWebapp::getInstance();
     $webapp_plugin_registrar->registerPlugin('twitter', 'TwitterPlugin');
     $this->config = Config::getInstance();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Loader::definePathConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/facebook/view/facebook.account.index.tpl');
     $this->view_mgr->addHelp('facebook', 'userguide/settings/plugins/facebook');
     /** set option fields **/
     // Application ID text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_app_id', 'label' => 'App ID', 'size' => 18));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('facebook_app_id', 'The Facebook plugin requires a valid App ID.');
     // Application Secret text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_secret', 'label' => 'App Secret', 'size' => 37));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('facebook_api_secret', 'The Facebook plugin requires a valid App Secret.');
     $max_crawl_time_label = 'Max crawl time in minutes';
     $max_crawl_time = array('name' => 'max_crawl_time', 'label' => $max_crawl_time_label, 'default_value' => '20', 'advanced' => true, 'size' => 3);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $max_crawl_time);
     $this->addToView('thinkup_site_url', Utils::getApplicationURL());
     $facebook_plugin = new FacebookPlugin();
     if ($facebook_plugin->isConfigured()) {
         $this->setUpFacebookInteractions($facebook_plugin->getOptionsHash());
         $this->addToView('is_configured', true);
     } else {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     }
     return $this->generateView();
 }
Пример #5
0
 public function write($id, $data)
 {
     $sessionTimeout = (int) Config::getInstance()->get("session_timeout", 3600);
     $redis = Redis::get();
     $redis->setex("sess:{$id}", $sessionTimeout, $data);
     return true;
 }
Пример #6
0
 /**
  *
  */
 private function __construct()
 {
     $this->pool = array();
     $obj = Config::getInstance();
     $this->config = $obj->config["databases"];
     return $this;
 }
Пример #7
0
 public function setUp()
 {
     parent::setUp();
     $config = Config::getInstance();
     $this->prefix = $config->getValue('table_prefix');
     $this->builders = self::buildData();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Utils::defineConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/geoencoder/view/geoencoder.account.index.tpl');
     $this->view_mgr->addHelp('geoencoder', 'userguide/settings/plugins/geoencoder');
     $this->addToView('message', 'This is the GeoEncoder plugin configuration page for ' . $this->owner->email . '.');
     /** set option fields **/
     // gmaps_api_key text field
     $name_field = array('name' => 'gmaps_api_key', 'label' => 'Google Maps API Key', 'size' => 55);
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field);
     $this->addPluginOptionRequiredMessage('gmaps_api_key', 'Please enter your Google Maps API Key');
     // distance_unit radio field
     $distance_unit_field = array('name' => 'distance_unit', 'label' => 'Unit of Distance');
     $distance_unit_field['values'] = array('Kilometers' => 'km', 'Miles' => 'mi');
     $distance_unit_field['default_value'] = 'km';
     $this->addPluginOption(self::FORM_RADIO_ELEMENT, $distance_unit_field);
     $plugin = new GeoEncoderPlugin();
     if (!$plugin->isConfigured()) {
         $this->addInfoMessage('Please complete plugin setup to start using it.', 'setup');
         $this->addToView('is_configured', false);
     } else {
         $this->addToView('is_configured', true);
     }
     return $this->generateView();
 }
Пример #9
0
 /**
  * Report installation version back to thinkup.com. If usage reporting is enabled, include instance username
  * and network.
  * @param Instance $instance
  * @return array ($report_back_url, $referer_url, $status, $contents)
  */
 public static function reportVersion(Instance $instance)
 {
     //Build URLs with appropriate parameters
     $config = Config::getInstance();
     $report_back_url = 'http://thinkup.com/version.php?v=' . $config->getValue('THINKUP_VERSION');
     //Explicity set referer for when this is called by a command line script
     $referer_url = Utils::getApplicationURL();
     //If user hasn't opted out, report back username and network
     if ($config->getValue('is_opted_out_usage_stats') === true) {
         $report_back_url .= '&usage=n';
     } else {
         $referer_url .= "?u=" . urlencode($instance->network_username) . "&n=" . urlencode($instance->network);
     }
     $in_test_mode = isset($_SESSION["MODE"]) && $_SESSION["MODE"] == "TESTS" || getenv("MODE") == "TESTS";
     if (!$in_test_mode) {
         //only make live request if we're not running the test suite
         //Make the cURL request
         $c = curl_init();
         curl_setopt($c, CURLOPT_URL, $report_back_url);
         curl_setopt($c, CURLOPT_REFERER, $referer_url);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
         $contents = curl_exec($c);
         $status = curl_getinfo($c, CURLINFO_HTTP_CODE);
         curl_close($c);
     } else {
         $contents = '';
         $status = 200;
     }
     return array($report_back_url, $referer_url, $status, $contents);
 }
Пример #10
0
 public static function get_available_domains()
 {
     $domain_configuration = Config::getInstance()->getConfig('domains');
     $configuration_keys = array_keys($domain_configuration);
     $available_domains = array_filter($configuration_keys, "self::is_domain");
     return $available_domains;
 }
Пример #11
0
 public function addAction()
 {
     $config = Config::getInstance();
     $config = $config->getConfig();
     $Cars = new Cars();
     $this->view->data = $Cars->getCategory();
     $model = $this->request->getPost('model');
     $marka = $this->request->getPost('marka_id');
     $opis = $this->request->getPost('opis');
     $zdjecie = $this->request->getFiles('zdjecie');
     if ($model == NULL && $marka == NULL && $opis == NULL && $zdjecie == NULL) {
         $this->view->display('add');
     } else {
         if ($model == NULL || $marka == NULL || $opis == NULL || $zdjecie == NULL) {
             echo "Uzupelnij wszystkie pola";
         } else {
             $podpis = date("Y-m-d G:i:s", time());
             $zdjecie = WideImage::loadFromUpload('zdjecie');
             $zdjecie->saveToFile($config['DOC_ROOT'] . $config['CUSTOM_IMG_DIR'] . $podpis . '.png');
             $Car = new Cars();
             $Car->saveCar($model, $marka, $opis, $podpis);
             header('location: ' . Url::getUrl('car', 'list', array('status' => 8)));
         }
     }
 }
Пример #12
0
 function run()
 {
     if ($this->running) {
         throw new \Exception(get_called_class() . '::run() was previously called!');
     }
     $this->running = true;
     $request = Request::getInstance();
     if ($request->exists(self::PATH_INFO_OVERRIDE_PARAM)) {
         $this->pathInfo = $request->get(self::PATH_INFO_OVERRIDE_PARAM, '/');
         $request->delete(self::PATH_INFO_OVERRIDE_PARAM);
     } else {
         $this->pathInfo = \ManiaLib\Utils\Arrays::getNotNull($_SERVER, 'PATH_INFO', '/');
     }
     list($this->controller, $this->action) = Route::getActionAndControllerFromRoute($this->pathInfo);
     $this->calledURL = $request->createLink();
     $viewsNS =& Config::getInstance()->viewsNS;
     $currentViewsNS = Config::getInstance()->namespace . '\\Views\\';
     if (!in_array($currentViewsNS, $viewsNS)) {
         array_unshift($viewsNS, $currentViewsNS);
     }
     try {
         Controller::factory($this->controller)->launch($this->action);
         Response::getInstance()->render();
     } catch (\Exception $e) {
         call_user_func(Bootstrapper::$errorHandlingCallback, $e);
         Response::getInstance()->render();
     }
 }
Пример #13
0
    /**
     * Constructor
     *
     * Sets default values all view templates have access to:
     *
     *  <code>
     *  //path of the ThinkUp installation site root as defined in config.inc.php
     *  {$site_root_path}
     *  //file the ThinkUp logo links to, 'index.php' by default
     *  {$logo_link}
     *  //application name
     *  {$app_title}
     *  </code>
     *  @param array $config_array Defaults to null; Override source_root_path, site_root_path, app_title, cache_pages,
     *  debug
     *
     */
    public function __construct($config_array=null) {
        if ($config_array==null) {
            $config = Config::getInstance();
            $config_array = $config->getValuesArray();
        }

        $src_root_path = $config_array['source_root_path'];
        $site_root_path = $config_array['site_root_path'];
        $app_title = $config_array['app_title'];
        $cache_pages = $config_array['cache_pages'];
        $debug =  $config_array['debug'];
        Utils::defineConstants();

        $this->Smarty();
        $this->template_dir = array( THINKUP_WEBAPP_PATH.'_lib/view', $src_root_path.'tests/view');
        $this->compile_dir = THINKUP_WEBAPP_PATH.'_lib/view/compiled_view/';
        $this->plugins_dir = array('plugins', THINKUP_WEBAPP_PATH.'_lib/view/plugins/');
        $this->cache_dir = THINKUP_WEBAPP_PATH.'_lib/view/compiled_view/cache';
        $this->caching = ($cache_pages)?1:0;
        $this->cache_lifetime = 300;
        $this->debug = $debug;

        $this->assign('app_title', $app_title);
        $this->assign('site_root_path', $site_root_path);
        $this->assign('logo_link', 'index.php');
    }
Пример #14
0
 public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
 {
     parent::generateInsight($instance, $last_week_of_posts, $number_days);
     $this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
     $post_dao = DAOFactory::getDAO('PostDAO');
     $user_dao = DAOFactory::getDAO('UserDAO');
     $service_user = $user_dao->getDetails($instance->network_user_id, $instance->network);
     $share_verb = $instance->network == 'twitter' ? 'retweeted' : 'reshared';
     foreach ($last_week_of_posts as $post) {
         $big_reshares = $post_dao->getRetweetsByAuthorsOverFollowerCount($post->post_id, $instance->network, $service_user->follower_count);
         if (isset($big_reshares) && sizeof($big_reshares) > 0) {
             if (!isset($config)) {
                 $config = Config::getInstance();
             }
             $post_link = '<a href="' . $config->getValue('site_root_path') . 'post/?t=' . $post->post_id . '&n=' . $post->network . '&v=fwds">';
             if (sizeof($big_reshares) > 1) {
                 $notification_text = "People with lots of followers {$share_verb} " . $post_link . "{$this->username}'s post</a>.";
             } else {
                 $follower_count_multiple = intval($big_reshares[0]->follower_count / $service_user->follower_count);
                 if ($follower_count_multiple > 1) {
                     $notification_text = "Someone with <strong>" . $follower_count_multiple . "x</strong> more followers than {$this->username} {$share_verb} " . $post_link . "this post</a>.";
                 } else {
                     $notification_text = "Someone with lots of followers {$share_verb} " . $post_link . "{$this->username}'s post</a>.";
                 }
             }
             //Replace each big resharer's bio line with the text of the post
             foreach ($big_reshares as $sharer) {
                 $sharer->description = '"' . $post->post_text . '"';
             }
             $simplified_post_date = date('Y-m-d', strtotime($post->pub_date));
             $this->insight_dao->insertInsight("big_reshare_" . $post->id, $instance->id, $simplified_post_date, "Big reshare!", $notification_text, basename(__FILE__, ".php"), Insight::EMPHASIS_HIGH, serialize($big_reshares));
         }
     }
     $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
 }
 /**
  * Set up
  * Initializes Config and Webapp objects
  */
 function setUp()
 {
     $config = Config::getInstance();
     $webapp = Webapp::getInstance();
     $crawler = Crawler::getInstance();
     parent::setUp();
 }
 /**
  * @param $serviceName
  * @param $requestPayload string Data encrypted using service private key (binary form!).
  */
 public function __construct($serviceName, $requestPayload)
 {
     $this->config = Config::getInstance();
     $this->service = $this->config->getService($serviceName);
     $this->encryptedPayload = $requestPayload;
     $this->decryptPayloadToCache();
 }
 public function setUp()
 {
     $config = Config::getInstance();
     $this->test_tweets = array("Hey @anildash think this up!", "If you're interested, @ me details", ".@anildash thinks so", "This is a tweet with multiple usernames like @waxpancake and @thinkupapp", "Blah blah blah (@username). Blah blah");
     $this->internally_linked_tweets = array('Hey <a href="' . $config->getValue('site_root_path') . 'user/?u=anildash&n=twitter&i=me">@anildash</a> think this up!', "If you're interested, @ me details", '.<a href="' . $config->getValue('site_root_path') . 'user/?u=anildash&n=twitter&i=me">@anildash</a> thinks so', 'This is a tweet with multiple usernames like <a href="' . $config->getValue('site_root_path') . 'user/?u=waxpancake&n=twitter&i=me">@waxpancake</a> ' . 'and <a href="' . $config->getValue('site_root_path') . 'user/?u=thinkupapp&n=twitter&i=me">@thinkupapp</a>', 'Blah blah blah (<a href="' . $config->getValue('site_root_path') . 'user/?u=username&n=twitter&i=me">@username</a>). Blah blah');
     $this->externally_linked_tweets = array('Hey <a href="https://twitter.com/intent/user?screen_name=anildash">@anildash</a> think this up!', "If you're interested, @ me details", '.<a href="https://twitter.com/intent/user?screen_name=anildash">@anildash</a> thinks so', 'This is a tweet with multiple usernames like ' . '<a href="https://twitter.com/intent/user?screen_name=waxpancake">@waxpancake</a> ' . 'and <a href="https://twitter.com/intent/user?screen_name=thinkupapp">@thinkupapp</a>', 'Blah blah blah (<a href="https://twitter.com/intent/user?screen_name=username">@username</a>). Blah blah');
 }
 public function setUp()
 {
     parent::setUp();
     $this->builder = self::buildData();
     $config = Config::getInstance();
     $config->setValue('debug', true);
 }
Пример #19
0
 public function setUp()
 {
     parent::setUp();
     StreamMessageQueueFactory::$queue = null;
     $this->logger = Logger::getInstance();
     $this->config = Config::getInstance();
 }
 public function control()
 {
     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 SmartyThinkUp();
             $es->caching = false;
             $config = Config::getInstance();
             $es->assign('apptitle', $config->getValue('app_title'));
             $es->assign('recovery_url', "session/reset.php?token={$token}");
             $es->assign('server', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost');
             $es->assign('site_root_path', $config->getValue('site_root_path'));
             $message = $es->fetch('_email.forgotpassword.tpl');
             Mailer::mail($_POST['email'], $config->getValue('app_title') . " Password Recovery", $message);
             $this->addSuccessMessage('Password recovery information has been sent to your email address.');
         } else {
             $this->addErrorMessage('Error: account does not exist.');
         }
     }
     $this->setViewTemplate('session.forgot.tpl');
     return $this->generateView();
 }
 public function authControl()
 {
     $config = Config::getInstance();
     Utils::defineConstants();
     $this->setViewTemplate(THINKUP_WEBAPP_PATH . 'plugins/facebook/view/facebook.account.index.tpl');
     /** set option fields **/
     // Application ID text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_app_id', 'label' => 'Application ID'));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('facebook_app_id', 'The Facebook plugin requires a valid Application ID.');
     // API Key text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_key', 'label' => 'API Key'));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('facebook_api_key', 'The Facebook plugin requires a valid API Key.');
     // Application Secret text field
     $this->addPluginOption(self::FORM_TEXT_ELEMENT, array('name' => 'facebook_api_secret', 'label' => 'Application Secret'));
     // add element
     // set a special required message
     $this->addPluginOptionRequiredMessage('facebook_api_secret', 'The Facebook plugin requires a valid Application Secret.');
     $plugin_option_dao = DAOFactory::getDAO('PluginOptionDAO');
     $options = $plugin_option_dao->getOptionsHash('facebook', true);
     //get cached
     if (isset($options['facebook_app_id']->option_value) && isset($options['facebook_api_secret']->option_value)) {
         $this->setUpFacebookInteractions($options);
     } else {
         $this->addErrorMessage('Please set your Facebook API key, application ID and secret.');
     }
     return $this->generateView();
 }
Пример #22
0
 /**
  * Factory for getting instances on cache objects.
  * You specify the driver to use as a parameter, and
  * it automatically falls back to the "NoCache" driver
  * if not found
  * @return \ManiaLib\Cache\CacheInterface
  */
 static function factory($driver = null)
 {
     try {
         switch ($driver) {
             case APC:
                 return static::getDriver('APC');
             case MEMCACHED:
                 try {
                     return static::getDriver('Memcached');
                 } catch (Exception $e) {
                     return static::getDriver('Memcache');
                 }
             case MEMCACHE:
                 return static::getDriver('Memcache');
             case MYSQL:
                 return static::getDriver('MySQL');
             default:
                 throw new Exception();
         }
     } catch (Exception $e) {
         $config = Config::getInstance();
         $driver = $config->fallbackDriver ?: 'NoCache';
         return static::getDriver($driver);
     }
 }
Пример #23
0
 public function testTerminalLogger()
 {
     $config = Config::getInstance();
     $config->setValue('log_location', false);
     $logger = Logger::getInstance();
     //        $logger->logStatus('Singleton logger should echo this', get_class($this));
 }
 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();
 }
Пример #25
0
 public static function send($data, $sampleRate = 1)
 {
     $config = Config::getInstance();
     if (!$config->isEnabled("statsd")) {
         return;
     }
     // sampling
     $sampledData = array();
     if ($sampleRate < 1) {
         foreach ($data as $stat => $value) {
             if (mt_rand() / mt_getrandmax() <= $sampleRate) {
                 $sampledData[$stat] = "{$value}|@{$sampleRate}";
             }
         }
     } else {
         $sampledData = $data;
     }
     if (empty($sampledData)) {
         return;
     }
     // Wrap this in a try/catch - failures in any of this should be silently ignored
     try {
         $host = $config->getConfig("statsd.host");
         $port = $config->getConfig("statsd.port");
         $fp = fsockopen("udp://{$host}", $port, $errno, $errstr);
         if (!$fp) {
             return;
         }
         foreach ($sampledData as $stat => $value) {
             fwrite($fp, "{$stat}:{$value}");
         }
         fclose($fp);
     } catch (Exception $e) {
     }
 }
    public function authControl() {
        $config = Config::getInstance();
        Utils::defineConstants();
        $this->setViewTemplate( THINKUP_WEBAPP_PATH.'plugins/hellothinkup/view/hellothinkup.account.index.tpl');
        $this->addToView('message',
            'Hello, world! This is the example plugin configuration page for  '.$this->owner->email .'.');

        /** set option fields **/
        // name text field
        $name_field = array('name' => 'testname', 'label' => 'Your Name'); // set an element name and label
        $name_field['default_value'] = 'ThinkUp User'; // set default value
        $this->addPluginOption(self::FORM_TEXT_ELEMENT, $name_field); // add element
        // set testname header
        $this->addPluginOptionHeader('testname', 'User Info'); // add a header for an element
        // set a special required message
        $this->addPluginOptionRequiredMessage('testname',
            'Please enter a name, because we\'d really like to have one...');

        // gender radio field
        $gender_field = array('name' => 'testradio', 'label' => 'You Like'); // set an element name and label
        $gender_field['values'] = array('Cookies' => 1, 'Cake' => 2, 'Other' => 3);
        $gender_field['default_value'] = '3'; // set default value
        $this->addPluginOption(self::FORM_RADIO_ELEMENT, $gender_field); // add element

        // Birth Year Select
        $bday_field = array('name' => 'testbirthyear', 'label' => 'Select The Year You Were Born');
        $years = array();
        $i = 1900;
        while ($i <= 2010) {
            $years['Born in ' . $i] = $i;
            $i++;
        }
        $bday_field['values'] =  $years;
        $bday_field['default_value'] = '2005';
        $this->addPluginOption(self::FORM_SELECT_ELEMENT, $bday_field);

        // Enable registration stuff
        $reg_field = array('name' => 'testregopen', 'label' => 'Open Registration');
        $this->addPluginOptionHeader('testregopen', 'Registration Options');
        $reg_field['values'] = array('Open' => 1, 'Closed' => 0);
        $this->addPluginOption(self::FORM_RADIO_ELEMENT, $reg_field);

        // registration key
        $reg_key = array('name' => 'RegKey', 'validation_regex' => '^\d+$');
        $this->addPluginOption(self::FORM_TEXT_ELEMENT, $reg_key);
        $this->setPluginOptionNotRequired('RegKey');
        $this->addPluginOptionRequiredMessage('RegKey',
            'Please enter interger value for RegKey');

        // advanced data
        $adv1 = array('name' => 'AdvancedInfo1', 'label' => '1st advanced field', 'advanced' => true);
        $this->addPluginOption(self::FORM_TEXT_ELEMENT, $adv1);
        $this->setPluginOptionNotRequired('AdvancedInfo1'); // by default not required

        $adv2 = array('name' => 'AdvancedInfo2', 'label' => '2nd advanced field', 'advanced' => true);
        $this->addPluginOption(self::FORM_TEXT_ELEMENT, $adv2);

        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();
 }
 /**
  * Create a new GettextZendTranslator and configure it with passed params
  * @param string|Zend_Locale $given_locale
  * @param string $filename
  * @param boolean $default_instance If none instance yet, this instance will be used whatever this param value is
  */
 public function __construct($given_locale = null, $filename = null, $default_instance = true)
 {
     if ($filename != null) {
         $this->filename = $filename;
     }
     self::$absolutePath = Config::getInstance()->getString('appRootDir') . self::DIR_LOCALES;
     $this->debugMode = Config::getInstance()->getBoolean('i18n/gettextZendTranslator/debug', false);
     $path = self::$absolutePath . self::DEFAULT_LOCALE . '/' . $this->filename;
     parent::__construct(self::GETTEXT, $path, self::DEFAULT_LOCALE);
     // Adding other existing locales
     $locales = $this->getAvailableLocales();
     foreach ($locales as $locale) {
         if ($locale != self::DEFAULT_LOCALE) {
             parent::addTranslation(self::$absolutePath . $locale . '/' . $this->filename, $locale);
         }
     }
     if ($given_locale == null) {
         if (($given_locale = Zend_Registry::get('Zend_Locale')) == null) {
             $given_locale = self::DEFAULT_LOCALE;
         }
     }
     $this->setLocale($given_locale);
     Zend_Registry::set('Zend_Translator', $this);
     if ($default_instance || self::$instance == null) {
         self::$instance = $this;
     }
 }
 public function setUp()
 {
     parent::setUp();
     $this->logger = Logger::getInstance();
     $this->config = Config::getInstance();
     $this->table_prefix = $this->config->getValue('table_prefix');
 }
Пример #30
0
 public function setUp()
 {
     parent::setUp();
     $config = Config::getInstance();
     $this->builders = self::buildData();
     $this->dao = new FavoritePostMySQLDAO();
 }