Example #1
0
 /**
  * Will call events as close as it gets to one hour. Event handlers
  * which use this MUST be as quick as possible, maybe only adding a
  * queue item to be handled later or something. Otherwise execution
  * will timeout for PHP - or at least cause unnecessary delays for
  * the unlucky user who visits the site exactly at one of these events.
  */
 public function callTimedEvents()
 {
     $timers = array('minutely' => 60, 'hourly' => 3600, 'daily' => 86400, 'weekly' => 604800);
     foreach ($timers as $name => $interval) {
         $run = false;
         $lastrun = new Config();
         $lastrun->section = 'cron';
         $lastrun->setting = 'last_' . $name;
         $found = $lastrun->find(true);
         if (!$found) {
             $lastrun->value = time();
             if ($lastrun->insert() === false) {
                 common_log(LOG_WARNING, "Could not save 'cron' setting '{$name}'");
                 continue;
             }
             $run = true;
         } elseif ($lastrun->value < time() - $interval) {
             $orig = clone $lastrun;
             $lastrun->value = time();
             $lastrun->update($orig);
             $run = true;
         }
         if ($run === true) {
             // such as CronHourly, CronDaily, CronWeekly
             Event::handle('Cron' . ucfirst($name));
         }
     }
 }
Example #2
0
 function test()
 {
     $config = new Config();
     $config->limit(1);
     $config->find(true);
     $config->free();
 }
Example #3
0
 public function demoAction()
 {
     $web_name = Config::find('web_name');
     $hello = "Hello World!";
     $this->assign("hello", $hello);
     $this->assign("name", $web_name);
     $this->display();
 }
 private function initConfig()
 {
     $configs = Config::find();
     foreach ($configs as $config) {
         $this->setInView($config->name, $config->value);
     }
     $this->appEmails = explode(",", Config::findFirst('name = "email"')->value);
 }
Example #5
0
 static function _getSettings()
 {
     $settings = array();
     $config = new Config();
     $config->find();
     while ($config->fetch()) {
         $settings[] = array($config->section, $config->setting, $config->value);
     }
     $config->free();
     return $settings;
 }
Example #6
0
 public function __construct($config = array())
 {
     if (empty($config)) {
         $this->config = Config::find("MEMCACHE_CONG");
     } else {
         $this->config = $config;
     }
     $mem = new Memcache();
     $this->cache = $mem;
     $mem->connect($this->config['host'], $this->config['port']);
 }
Example #7
0
 public static function getInstance($config = array())
 {
     /*{{{*/
     if (empty($config)) {
         $config = Config::find("DB_CONF");
     }
     $key = md5(serialize($config));
     if (!isset(self::$_container[$key]) || !self::$_container[$key] instanceof DBPDO) {
         $final_config = array();
         foreach (self::$_default_config as $index => $value) {
             $final_config[$index] = isset($config[$index]) && !empty($config[$index]) ? $config[$index] : self::$_default_config[$index];
         }
         self::$_container[$key] = new DBPDO($final_config);
     }
     return self::$_container[$key];
 }
Example #8
0
 private function initSmarty()
 {
     /*{{{*/
     $smarty_conf = Config::find("smarty");
     if (!$smarty_conf['using']) {
         return;
     }
     include LIB_PATH . '/Templates/drivers/smarty/Smarty.class.php';
     $this->tpl_engine = new Smarty();
     $this->tpl_engine->compile_dir = ROOT_PATH . "/cache/templates_c/";
     $this->tpl_engine->config_dir = ROOT_PATH . "/cache/configs/";
     $this->tpl_engine->cache_dir = ROOT_PATH . "/cache/cache/";
     $this->tpl_engine->template_dir = $this->tpl_root;
     $this->tpl_engine->left_delimiter = $smarty_conf['left'];
     $this->tpl_engine->right_delimiter = $smarty_conf['right'];
     $this->tpl_engine->force_compile = false;
     $this->tpl_engine->debugging = $smarty_conf['debug'];
     $this->tpl_suffix = $smarty_conf['tpl_suffix'];
 }
Example #9
0
 public function getConfig()
 {
     if (!$this->config) {
         $cm = $this->getBootstrap()->getResource('cachemanager');
         $cache = $cm->getCache('longcache');
         if (!($this->config = $cache->load('dynamic_config'))) {
             $options = $this->getOptions();
             $id = $options['id'];
             $configModel = new Config();
             // do not use findOne
             $config = $configModel->find($id)->current();
             $this->config = $config->getConfigValues();
             $cache->save($this->config);
         }
         $mainConfig = Zend_Registry::get('config');
         $mainConfig = array_merge($mainConfig, $this->config);
         Zend_Registry::set('config', $mainConfig);
     }
     return $this->config;
 }
Example #10
0
 static function _getSettings()
 {
     $c = self::memcache();
     if (!empty($c)) {
         $settings = $c->get(common_cache_key(self::settingsKey));
         if ($settings !== false) {
             return $settings;
         }
     }
     $settings = array();
     $config = new Config();
     $config->find();
     while ($config->fetch()) {
         $settings[] = array($config->section, $config->setting, $config->value);
     }
     $config->free();
     if (!empty($c)) {
         $c->set(common_cache_key(self::settingsKey), $settings);
     }
     return $settings;
 }
Example #11
0
 /**
  * Delete a design setting
  *
  * // XXX: Maybe this should go in Design? --Z
  *
  * @return mixed $result false if something didn't work
  */
 function deleteSetting($section, $setting)
 {
     $config = new Config();
     $config->section = $section;
     $config->setting = $setting;
     if ($config->find(true)) {
         $result = $config->delete();
         if (!$result) {
             common_log_db_error($config, 'DELETE', __FILE__);
             // TRANS: Client error message
             $this->clientError(_("Unable to delete design setting."));
             return null;
         }
     }
     return $result;
 }
Example #12
0
END_OF_SETCONFIG_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
if (empty($args)) {
    if (have_option('a', 'all')) {
        foreach ($config as $section => $section_value) {
            foreach ($section_value as $setting => $value) {
                if (have_option('v', 'verbose') || !is_array($value)) {
                    // Don't print array's without the verbose flag
                    printf("%-20s %-20s %s\n", $section, $setting, var_export($value, true));
                }
            }
        }
    } else {
        $count = 0;
        $config = new Config();
        $config->find();
        while ($config->fetch()) {
            $count++;
            printf("%-20s %-20s %s\n", $config->section, $config->setting, var_export($config->value, true));
        }
        if ($count == 0) {
            print "No configuration set in database for this site.\n";
        }
    }
    exit(0);
}
if (count($args) < 2 || count($args) > 3) {
    show_help();
    exit(1);
}
$section = $args[0];
Example #13
0
 private function setConfigsFromDB(){
     $result = \Config::find('all', array('conditions' => array()));
     foreach ($result as &$rec) {
         switch($rec->config_key){
             case 'enableordrlis':
                 $this->enableordrlis = (($rec->config_val === '1')?true:false);
             break;
             case 'enableordrtasks':
                 $this->enableordrtasks = (($rec->config_val === '1')?true:false);
             break;
             case 'enableordrtaskpeople':
                 $this->enableordrtaskpeople = (($rec->config_val === '1')?true:false);
             break;
             case 'enableordrpayments':
                 $this->enableordrpayments = (($rec->config_val === '1')?true:false);
             break;
             case 'enableordermilestones':
                 $this->enableordermilestones = (($rec->config_val === '1')?true:false);
             break;
             case 'ordercostamountfrom':
                 $this->ordercostamountfrom = ((is_numeric($rec->config_val))?(int)$rec->config_val:null);
             break;
             case 'ordertaskcostamountfrom':
                 $this->ordertaskcostamountfrom = ((is_numeric($rec->config_val))?(int)$rec->config_val:null);
             break;
             case 'enablediscount':
                 $this->enablediscount = (($rec->config_val === '1')?true:false);
             break;
             case 'orderdiscfor':
                 $this->orderdiscfor = ((is_numeric($rec->config_val))?(int)$rec->config_val:null);
             break;
             case 'enableordername':
                 $this->enableordername = (($rec->config_val === '1')?true:false);
             break;
             case 'enableprdauxname':
                 $this->enableprdauxname = (($rec->config_val === '1')?true:false);
             break;
             case 'enablepplauxname':
                 $this->enablepplauxname = (($rec->config_val === '1')?true:false);
             break;
             case 'enablecontact':
                 $this->enablecontact = (($rec->config_val === '1')?true:false);
             break;
             case 'enablepurchase':
                 $this->enablepurchase = (($rec->config_val === '1')?true:false);
             break;
             case 'enablestock':
                 $this->enablestock = (($rec->config_val === '1')?true:false);
             break;                
             case 'enablelocality':
                 $this->enablelocality = (($rec->config_val === '1')?true:false);
             break;
             case 'enablecity':
                 $this->enablecity = (($rec->config_val === '1')?true:false);
             break;
             case 'enablestate':
                 $this->enablestate = (($rec->config_val === '1')?true:false);
             break;
             case 'enablecountry':
                 $this->enablecountry = (($rec->config_val === '1')?true:false);
             break;
             case 'enabletax':
                 $this->enabletax = (($rec->config_val === '1')?true:false);
             break;
             case 'enableinlinepayments':
                 $this->enableinlinepayments = (($rec->config_val === '1')?true:false);
             break;
             case 'sptype':
                 $this->sptype = ((is_numeric($rec->config_val))?(int)$rec->config_val:0);
             break;
             case 'isordridauto':
                 $this->isordridauto = ((is_numeric($rec->config_val))?(int)$rec->config_val:0);
             break;
             case 'moperinvoice':
                 $this->moperinvoice = (($rec->config_val === '1')?true:false);
             break;
             case 'ispplcodeauto':
                 $this->ispplcodeauto = ((is_numeric($rec->config_val))?(int)$rec->config_val:0);
             break;
             case 'iscustcodeauto':
                     $this->iscustcodeauto = ((is_numeric($rec->config_val))?(int)$rec->config_val:0);
                 break;
             case 'issplrcodeauto':
                     $this->issplrcodeauto = ((is_numeric($rec->config_val))?(int)$rec->config_val:0);
                 break;
             case 'isprdcodeauto':
                     $this->isprdcodeauto = ((is_numeric($rec->config_val))?(int)$rec->config_val:0);
                 break;
             case 'daystocheckfordue':
                 $this->daystocheckfordue = ((is_numeric($rec->config_val))?(int)$rec->config_val:null);
             break;
             case 'daystocheckforoverdue':
                 $this->daystocheckforoverdue = ((is_numeric($rec->config_val))?(int)$rec->config_val:null);
             break;
             case 'taskppltax':
                 $this->taskppltax = ((is_numeric($rec->config_val))?(int)$rec->config_val:null);
             break;
             case 'directorder':
                 $this->directorder = (($rec->config_val === '1')?true:false);
             break;
             case 'directinvoice':
                 $this->directinvoice = (($rec->config_val === '1')?true:false);
             break;
             case 'isinlineotentry':
                 $this->isinlineotentry = (($rec->config_val === '1')?true:false);
             break;
             case 'isinlinemsentry':
                 $this->isinlinemsentry = (($rec->config_val === '1')?true:false);
             break;
             case 'enableordrdn':
                 $this->enableordrdn = (($rec->config_val === '1')?true:false);
             break;
             case 'discentry':
                 $this->discentry = ((is_numeric($rec->config_val))?(int)$rec->config_val:null);
             break;
             case 'enableexpctdstartdt':
                 $this->enableexpctdstartdt = (($rec->config_val === '1')?true:false);
             break;
             case 'enableexpctdenddt':
                 $this->enableexpctdenddt = (($rec->config_val === '1')?true:false);
             break;                    
         }
     }
     if(is_null($this->enableordrlis)
             || is_null($this->enableordrtasks)
             || is_null($this->enableordrtaskpeople)
             || is_null($this->enableordrpayments)
             || is_null($this->enableordermilestones)
             || is_null($this->ordercostamountfrom)
             || is_null($this->ordertaskcostamountfrom)
             || is_null($this->enablediscount)
             || is_null($this->orderdiscfor)
             || is_null($this->enableordername)
             || is_null($this->enableprdauxname)
             || is_null($this->enablepplauxname)
             || is_null($this->enablecontact)
             || is_null($this->enablepurchase)
             || is_null($this->enablestock)
             || is_null($this->enablelocality)
             || is_null($this->enablecity)
             || is_null($this->enablestate)
             || is_null($this->enablecountry)
             || is_null($this->enabletax)
             || is_null($this->enableinlinepayments)
             || is_null($this->sptype)
             || is_null($this->isordridauto)
             || is_null($this->moperinvoice)
             || is_null($this->ispplcodeauto)
             || is_null($this->iscustcodeauto)
             || is_null($this->issplrcodeauto)
             || is_null($this->isprdcodeauto)
             || is_null($this->daystocheckfordue)
             || is_null($this->daystocheckforoverdue)
             || is_null($this->taskppltax)
             || is_null($this->directorder)
             || is_null($this->directinvoice)
             || is_null($this->isinlineotentry)
             || is_null($this->isinlinemsentry)
             || is_null($this->enableordrdn)
             || is_null($this->discentry)
             || is_null($this->enableexpctdstartdt)
             || is_null($this->enableexpctdenddt)
     ){
         return false;
     }
     return true;
 }