Exemple #1
0
 public function init()
 {
     // Get all settings
     Shineisp_Registry::set('Settings', Settings::getAll());
     // Statuses are used everywhere in system, so we need to make just one query
     Shineisp_Registry::set('Status', Statuses::getAll());
 }
Exemple #2
0
 public function preStmtExecute(Doctrine_Event $event)
 {
     // Check if the administrator has enabled the query logging feature
     if (Settings::findbyParam('debug_queries')) {
         $breadcrumps = array();
         $query = $event->getQuery();
         $params = $event->getParams();
         $callers = array_reverse(debug_backtrace(), true);
         $callers = array_slice($callers, 4, count($callers) - 10);
         foreach ($callers as $caller) {
             $class = !empty($caller['class']) ? $caller['class'] : null;
             $breadcrumps[] = $class . "->" . $caller['function'];
         }
         $strBreadcrump = "System: " . implode(" / ", $breadcrumps);
         //the below makes some naive assumptions about the queries being logged
         while (sizeof($params) > 0) {
             $param = array_shift($params);
             if (!is_numeric($param)) {
                 $param = sprintf("'%s'", $param);
             }
             $query = substr_replace($query, $param, strpos($query, '?'), 1);
         }
         Shineisp_Commons_Utilities::log($query, "queries.log");
         Shineisp_Commons_Utilities::log($strBreadcrump, "debug.log", Zend_Log::DEBUG);
         // Increase query counter
         $queryCount = Shineisp_Registry::isRegistered('querycount') ? Shineisp_Registry::get('querycount') : 0;
         $queryCount = $queryCount + 1;
         Shineisp_Registry::set('querycount', $queryCount);
     }
 }
Exemple #3
0
 /**
  * Get the Status ID
  * 
  * @param string $status 
  * @param string $section
  */
 public static function id($status, $section = "generic")
 {
     $statuses = Shineisp_Registry::get('Status');
     if (empty($statuses)) {
         Shineisp_Registry::set('Status', self::getAll());
     }
     if (!empty($status)) {
         $status = strtolower($status);
     }
     $section = strtolower($section);
     return intval(Shineisp_Registry::get('Status')->{$section}->{$status}->status_id) ? intval(Shineisp_Registry::get('Status')->{$section}->{$status}->status_id) : null;
     return null;
 }
Exemple #4
0
 public function init()
 {
     // Get authenticated user
     $auth = Zend_Auth::getInstance()->getIdentity();
     // Store logged ISP. I'm inside admin, se we use only the logged user
     if (isset($auth['isp_id'])) {
         $isp_id = intval($auth['isp_id']);
         $ISP = new Isp();
         Shineisp_Registry::set('ISP', $ISP->find($isp_id));
     }
     // Load all the status in the registry
     $statusreg = Shineisp_Registry::get('Status');
     if (empty($statusreg)) {
         $status = Statuses::getAll();
         Shineisp_Registry::set('Status', $status);
     }
     parent::init();
 }
Exemple #5
0
 public function init()
 {
     try {
         // Store logged ISP. I'm in the public area, se we use only the URL
         $ISP = Isp::findByUrl($_SERVER['HTTP_HOST']);
         if (!empty($ISP)) {
             Shineisp_Registry::set('ISP', $ISP);
         }
         // Load all the status in the registry
         $statusreg = Shineisp_Registry::get('Status');
         if (empty($statusreg)) {
             $status = Statuses::getAll();
             Shineisp_Registry::set('Status', $status);
         }
     } catch (Exception $e) {
         Shineisp_Commons_Utilities::log(__METHOD__ . " " . $e->getMessage());
     }
     parent::init();
 }
Exemple #6
0
 /**
  * Set the language object variable
  * @param $locale
  */
 public static function setDefaultLanguage($path, $locale)
 {
     $zl = new Zend_Locale();
     if (!empty($locale)) {
         $zl->setLocale($locale);
         Shineisp_Registry::set('Zend_Locale', $zl);
     }
 }
Exemple #7
0
 /**
  * Load of the configuration file
  * @return SimpleXMLElement
  */
 public static function loadConfig()
 {
     $confFile = APPLICATION_PATH . "/configs/config.xml";
     try {
         if (file_exists($confFile) && is_readable($confFile)) {
             $config = Shineisp_Commons_Utilities::readfile($confFile);
             if (!empty($config)) {
                 $config = new Zend_Config_Xml($confFile);
                 if (simplexml_load_file($confFile)) {
                     Shineisp_Registry::set('config', $config);
                     return simplexml_load_file($confFile);
                 } else {
                     throw new Exception("XML Config file is not readable or not well-formed");
                 }
             }
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         echo "<xmp>";
         echo $e->getTraceAsString();
         echo "</xmp>";
         exit;
     }
 }