/** * Constructor * * Attempts to load the correct layout xml file * * @param string $name * @return object */ public function __construct($name = null) { if (pathinfo($name, PATHINFO_EXTENSION)) { $this->path = $name; $this->name = pathinfo($name, PATHINFO_FILENAME); } else { $this->path = $this->_zula->getDir('config') . '/layouts/' . $name . '.xml'; $this->name = $name; } if (Registry::has('sql')) { // Find the regex for this layout $pdoSt = $this->_sql->prepare('SELECT regex FROM {PREFIX}layouts WHERE name = ?'); $pdoSt->execute(array($name)); if ($regex = $pdoSt->fetchColumn()) { $this->regex = $regex; } $pdoSt->closeCursor(); } // Load the DomDocument (or create if needed) $this->dom = new DomDocument('1.0', 'UTF-8'); $this->dom->preserveWhiteSpace = false; $this->dom->formatOutput = true; if (is_file($this->path)) { $this->dom->load($this->path); } else { $this->dom->appendChild($this->dom->createElement('controllers')); } }
public function metaUser($userid, $subscriptionid = null) { if (empty($userid) && !empty($subscriptionid)) { $userid = aecUserHelper::UserIDfromSubscriptionID($subscriptionid); } $this->meta = new metaUserDB(); $this->meta->loadUserid($userid); $this->cmsUser = false; $this->hasCBprofile = false; $this->hasJSprofile = false; $this->userid = 0; $this->hasSubscription = 0; $this->objSubscription = null; $this->focusSubscription = null; if ($userid) { $this->cmsUser = new cmsUser(); $this->cmsUser->load($userid); $this->userid = $userid; if (!empty($subscriptionid)) { $aecid = $subscriptionid; } else { $aecid = aecUserHelper::SubscriptionIDfromUserID($userid); } if ($aecid) { $this->objSubscription = new Subscription(); $this->objSubscription->load($aecid); $this->focusSubscription = new Subscription(); $this->focusSubscription->load($aecid); $this->hasSubscription = 1; $this->temporaryRFIX(); } } }
/** * Carrega os helpers que serão usados no sistema */ public function loads() { $lista = $this->helpers->load(); if (count($lista) > 0) { foreach ($lista as $key => $value) { $exist = false; $class = 'Core\\Helpers\\' . $value['class']; $class_name = ROOT . str_replace('\\', DS, $class) . '.php'; $class_name = str_replace(DS . 'App' . DS, DS . 'src' . DS, $class_name); if (file_exists($class_name)) { $exist = true; } else { $class = 'App\\Helpers\\' . $value['class']; $class_name = ROOT . str_replace('\\', DS, $class) . '.php'; $class_name = str_replace(DS . 'App' . DS, DS . 'src' . DS, $class_name); if (file_exists($class_name)) { $exist = true; } } if ($exist === true) { $this->{$value['nome']} = new $class($this->request); } else { throw new Exception('Helper não localizado.'); } } } }
/** * Set up the contrib object. */ public function load_contrib_object() { if (!is_object($this->contrib)) { $this->load_topic_object(); $this->contrib = new titania_contribution(); $this->contrib->load($this->post->topic->parent_id); } }
/** * Set up contrib object. */ public function load_source_object() { if (!is_object($this->contrib)) { $this->contrib = new titania_contribution(); $this->contrib->load((int) $this->attention_object_id); } return is_object($this->contrib) ? true : false; }
/** * Constructor of the container class * * @param $filename string filename for a passwd type file * @return object Returns an error object if something went wrong */ function Auth_Container_SMBPasswd($filename) { $this->pwfile = new File_SMBPasswd($filename, 0); if (!$this->pwfile->load()) { PEAR::raiseError("Error while reading file contents.", 41, PEAR_ERROR_DIE); return; } }
/** * Handles calls to class methods. * * @param string $name Method name * @param array $params Method parameters */ public function __call($name, $params) { $callback = $this->dispatcher->get($name); if (is_callable($callback)) { return $this->dispatcher->run($name, $params); } $shared = !empty($params) ? (bool) $params[0] : true; return $this->loader->load($name, $shared); }
/** * Handles calls to static methods. * * @param string $name Method name * @param array $args Method parameters */ public static function __callStatic($name, $params) { $callback = self::$dispatcher->get($name); if (is_callable($callback)) { return self::$dispatcher->run($name, $params); } $shared = !empty($params) ? (bool) $params[0] : true; return self::$loader->load($name, $shared); }
/** * Returns active shop object. * * @return oxshop $oUser */ protected function _getActShop() { // shop is allready loaded if ($this->_oActShop !== null) { return $this->_oActShop; } $this->_oActShop = oxNew('oxshop'); $this->_oActShop->load($this->getConfig()->getShopId()); return $this->_oActShop; }
/** * Check the request parameters to see which course was specified. */ function process_request() { $id = required_param('id', PARAM_INT); if (!($this->course = get_record('course', 'id', $id))) { error('Could not find course.'); } $this->sloodle_course = new SloodleCourse(); if (!$this->sloodle_course->load($this->course)) { error(get_string('failedcourseload', 'sloodle')); } }
/** * Handles calls to class methods. * * @param string $name Method name * @param array $params Method parameters * @return mixed Callback results * @throws \Exception */ public function __call($name, $params) { $callback = $this->dispatcher->get($name); if (is_callable($callback)) { return $this->dispatcher->run($name, $params); } if (!$this->loader->get($name)) { throw new \Exception("{$name} must be a mapped method."); } $shared = !empty($params) ? (bool) $params[0] : true; return $this->loader->load($name, $shared); }
/** * Constructor * * @param mixed $oid Object Id * @return void */ public function __construct($oid = null) { // create database object $this->_db = \App::get('db'); // create page cateogry jtable object $this->_tbl = new $this->_tbl_name($this->_db); // load object if (is_numeric($oid)) { $this->_tbl->load($oid); } else { if (is_object($oid) || is_array($oid)) { $this->bind($oid); } } }
/** * Parse the file in chunks * @param int $size * @param $callback * @throws \Exception * @return void */ public function chunk($size = 10, $callback = null) { // Check if the chunk filter has been enabled if (!in_array('chunk', $this->filters['enabled'])) { throw new \Exception("The chunk filter is not enabled, do so with ->filter('chunk')"); } // Get total rows $totalRows = $this->getTotalRowsOfFile(); // Only read $this->reader->setReadDataOnly(true); // Start the chunking for ($startRow = 0; $startRow < $totalRows; $startRow += $chunkSize) { // Set start index $startIndex = $startRow == 0 ? $startRow : $startRow - 1; $chunkSize = $startRow == 0 ? $size + 1 : $size; // Set the rows for the chunking $this->filter->setRows($startRow, $chunkSize); // Load file with chunk filter enabled $this->excel = $this->reader->load($this->file); // Slice the results $results = $this->get()->slice($startIndex, $chunkSize); // Do a callback if (is_callable($callback)) { call_user_func($callback, $results); } $this->_reset(); unset($this->excel, $results); } }
/** * Returns selected Payment * * @return object */ public function getSelUserPayment() { if ($this->_oUserPayment == null) { $this->_oUserPayment = false; $sPaymentId = $this->getPaymentId(); if ($sPaymentId != "-1" && isset($sPaymentId)) { $this->_oUserPayment = oxNew("oxuserpayment"); $this->_oUserPayment->load($sPaymentId); $sTemplate = $this->_oUserPayment->oxuserpayments__oxvalue->value; // generate selected paymenttype $oPaymentTypes = $this->getPaymentTypes(); foreach ($oPaymentTypes as $oPayment) { if ($oPayment->oxpayments__oxid->value == $this->_oUserPayment->oxuserpayments__oxpaymentsid->value) { $oPayment->selected = 1; // if there are no values assigned we set default from paymenttype if (!$sTemplate) { $sTemplate = $oPayment->oxpayments__oxvaldesc->value; } break; } } $this->_oUserPayment->setDynValues(oxRegistry::getUtils()->assignValuesFromText($sTemplate)); } } return $this->_oUserPayment; }
/** * Check and process the request parameters. */ function process_request() { // Fetch some parameters $this->moodleuserid = required_param('id', PARAM_RAW); $this->deletesloodleentry = optional_param('delete', null, PARAM_INT); $this->userconfirmed = optional_param('confirm', null, PARAM_RAW); $this->courseid = optional_param('course', SITEID, PARAM_INT); $this->searchstr = addslashes(optional_param('search', '', PARAM_TEXT)); $this->deleteuserobjects = optional_param('deleteuserobjects', null, PARAM_TEXT); // If we are viewing 'all' avatar entries, then revert to the site course if (strcasecmp($this->moodleuserid, 'all') == 0) { $this->courseid = SITEID; } // Fetch our Moodle and SLOODLE course data if (!($this->course = get_record('course', 'id', $this->courseid))) { error('Could not find course.'); } $this->sloodle_course = new SloodleCourse(); if (!$this->sloodle_course->load($this->course)) { error(get_string('failedcourseload', 'sloodle')); } $this->start = optional_param('start', 0, PARAM_INT); if ($this->start < 0) { $this->start = 0; } }
/** * Read a url object from DB * * @param integer $id */ public function getUrl($id) { if (is_null($this->_url)) { $this->_url =& JTable::getInstance('urls', 'Sh404sefTable'); $result = $this->_url->load($id); } return $this->_url; }
/** * Returns an item as an object * identified by its db id * * @param integer $id */ public function getById($id) { // if no cached data, fetch from DB or create if (is_null($this->_data) || $this->_data->id != $id) { jimport('joomla.database.table'); // get a table instance $this->_data =& JTable::getInstance($this->_defaultTable, 'Sh404sefTable'); // load from table $this->_data->load($id); // set error $error = $this->_data->getError(); if (!empty($error)) { $this->setError($error); } } return $this->_data; }
/** Query the solr instance * * @param string $query */ public function moreLikeThis($query) { $key = md5('mlt' . $query); if (!$this->_cache->test($key)) { $mlt = $this->_solr; $mlt->setFields(array('objecttype', 'broadperiod', 'description', 'notes')); $mlt->setQuery($query); $solrResponse = $mlt->executeQuery(); $this->_cache->save($solrResponse); } else { $solrResponse = $this->_cache->load($key); } if ($solrResponse) { return $this->buildHtml($solrResponse); } else { return false; } }
/** * Load the model from the element id * * @param string $key Db table key * @param int $id Key value * * @return FabTable join */ public function getJoinFromKey($key, $id) { if (!isset($this->join)) { $this->join = FabTable::getInstance('join', 'FabrikTable'); $this->join->load(array($key => $id)); $this->paramsType($this->join); } return $this->join; }
/** * Connect to mysql * * @author KnowledgeTree Team * @params none * @access private * @return object mysql connection */ private function connectMysql() { $con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); if (!$con) { $this->error['con'] = "Could not connect: "; return false; } return $con; }
/** * Save some data in a cache * * @param mixed $data data to put in cache (can be another type than string if automatic_serialization is on) * @param cache $id cache id (if not set, the last cache id will be used) * @param array $tags cache tags * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime) * @return boolean true if no problem */ public function save($data, $id = null, $tags = array(), $specificLifetime = false) { if (!$this->_options['caching']) { return true; } if (is_null($id)) { $id = $this->_lastId; } else { $id = $this->_id($id); } self::_validateIdOrTag($id); self::_validateTagsArray($tags); if ($this->_options['automatic_serialization']) { // we need to serialize datas before storing them $data = serialize($data); } else { if (!is_string($data)) { Zend_Cache::throwException("Datas must be string or set automatic_serialization = true"); } } // automatic cleaning if ($this->_options['automatic_cleaning_factor'] > 0) { $rand = rand(1, $this->_options['automatic_cleaning_factor']); if ($rand == 1) { if ($this->_backend->isAutomaticCleaningAvailable()) { $this->clean(Zend_Cache::CLEANING_MODE_OLD); } else { $this->_log('Zend_Cache_Core::save() / automatic cleaning is not available with this backend'); } } } if ($this->_options['ignore_user_abort']) { $abort = ignore_user_abort(true); } $result = $this->_backend->save($data, $id, $tags, $specificLifetime); if ($this->_options['ignore_user_abort']) { ignore_user_abort($abort); } if (!$result) { // maybe the cache is corrupted, so we remove it ! if ($this->_options['logging']) { $this->_log("Zend_Cache_Core::save() : impossible to save cache (id={$id})"); } $this->remove($id); return false; } if ($this->_options['write_control']) { $data2 = $this->_backend->load($id, true); if ($data != $data2) { $this->_log('Zend_Cache_Core::save() / write_control : written and read data do not match'); $this->remove($id); return false; } } return true; }
/** * @access public * @param string $file_name * @param string $path_save * @param string $path_templates * @param boolean $format_output * @param boolean $white_space * @return void */ public function load($file_name, $path_save, $path_templates, $format_output, $white_space) { try { $this->fileName = $file_name; $this->pathTemplates = Fonction::removeLastSlash($path_templates); $this->pathSave = Fonction::removeLastSlash($path_save); $this->core = new DOMDocument(); $this->core->preserveWhiteSpace = $white_space; $this->core->formatOutput = $format_output; if (!@$this->core->load($this->pathTemplates . '/' . $this->fileName)) { throw new Exception(''); } $this->xpath = new DOMXPath($this->core); $this->root = $this->core->documentElement; $this->nameSpaces = Fonction::getNamespace(); } catch (Exception $e) { throw $e; } }
/** * Method to get category by catid. * * @param integer $pk Category id. * * @return mixed Category object or false. */ function getCategory() { if (!empty($this->category)) { return $this->category; } $pk = $this->getState('category.id'); $this->category = JTable::getInstance('Category'); $this->category->load($pk); return $this->category; }
/** * Handle various admin operations /admin/xxxx * * @param object $context The context object for the site * * @return string A template name */ public function handle($context) { $tpl = 'support/admin.twig'; $rest = $context->rest(); switch ($rest[0]) { case 'pages': $tpl = 'support/pages.twig'; break; case 'department': $tpl = 'support/department.twig'; break; case 'publication': $tpl = 'support/publication.twig'; break; case 'contexts': $tpl = 'support/contexts.twig'; break; case 'roles': $tpl = 'support/roles.twig'; break; case 'users': $tpl = 'support/users.twig'; break; case 'info': $_SERVER['PHP_AUTH_PW'] = '*************'; # hide the password in case it is showing. phpinfo(); exit; case 'edit': // Edit something - at the moment just a User if (count($rest) < 3) { (new Web())->bad(); } $kind = $rest[1]; $obj = $context->load($kind, $rest[2]); if (!is_object($obj)) { (new Web())->bad(); } if (($bid = $context->postpar('bean', '')) != '') { # this is a post if ($bid != $obj->getID()) { # something odd... (new Web())->bad(); } $obj->edit($context); // The edit call might divert to somewhere else so sometimes we may not get here. } $context->local()->addval($kind, $obj); $tpl = 'support/edit' . $kind . '.twig'; break; default: break; } return $tpl; }
/** * Hard delete a post */ public function hard_delete() { if (!$this->topic->topic_posts) { if (!$this->topic->load($this->topic_id)) { return false; } } // Update the postcount for the topic $this->update_topic_postcount(true); // Set the visibility appropriately if no posts are visibile to the public/authors $flags = count::get_flags(access::PUBLIC_LEVEL); if (count::from_db($this->topic->topic_posts, $flags) <= 0) { // There are no posts visible to the public, change it to authors level access $this->topic->topic_access = access::AUTHOR_LEVEL; $flags = count::get_flags(access::AUTHOR_LEVEL); if (count::from_db($this->topic->topic_posts, $flags) <= 0) { // There are no posts visible to authors, change it to teams level access $this->topic->topic_access = access::TEAM_LEVEL; } } // Sync the first topic post if required if ($this->post_id == $this->topic->topic_first_post_id) { $this->topic->sync_first_post($this->post_id); } // Sync the last topic post if required if ($this->post_id == $this->topic->topic_last_post_id) { $this->topic->sync_last_post($this->post_id); } // Submit the topic to store the updated information $this->topic->submit(); // Remove from the search index $this->search_manager->delete($this->post_type, $this->post_id); // @todo remove attachments and other things // Remove any attention items $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . ' WHERE attention_object_type = ' . TITANIA_POST . ' AND attention_object_id = ' . $this->post_id; phpbb::$db->sql_query($sql); // Decrement the user's postcount if we must if (!$this->post_deleted && $this->post_approved && in_array($this->post_type, titania::$config->increment_postcount)) { phpbb::update_user_postcount($this->post_user_id, '-'); } // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this); // Initiate self-destruct mode parent::delete(); // Update topics posted table $this->topic->update_posted_status('remove', $this->post_user_id); // Check if the topic is empty $flags = count::get_flags(access::TEAM_LEVEL, true, true); if (count::from_db($this->topic->topic_posts, $flags) <= 0) { $this->topic->delete(); } }
/** * oxActions::stop() test case * stops the current promo action and test if oxactiveto equals the current date. * * @return null */ public function testStop() { oxTestModules::addFunction('oxUtilsDate', 'getTime', '{return ' . time() . ';}'); $this->_oPromo->stop(); $iNow = strtotime(date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime())); $this->assertEquals(date('Y-m-d H:i:s', $iNow), $this->_oPromo->oxactions__oxactiveto->value); $id = $this->_oPromo->getId(); $this->_oPromo = oxNew('oxActions'); $this->_oPromo->load($id); $this->assertEquals(date('Y-m-d H:i:s', $iNow), $this->_oPromo->oxactions__oxactiveto->value); }
/** * Loads a cached object * * @param string $name * @return mixed */ public function loadCache($name) { if ($this->hasCache) { $cacheId = $this->prefix . $name . "_" . md5($name); if ($data = $this->cache->load($cacheId)) { return $data; } return false; } return false; }
private function checkDb() { // defaults $this->temp_variables['dbConnectAdmin'] = ''; $this->temp_variables['dbConnectUser'] = ''; $this->temp_variables['dbPrivileges'] = ''; $this->temp_variables['dbTransaction'] = ''; $html = '<td><div class="%s"></div></td>' . '<td %s>%s</td>'; // retrieve database information from session $dbconf = $this->getDataFromSession("database"); //print_r($dbconf); // make db connection - admin $loaded = $this->_dbhandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); if (!$loaded) { $this->temp_variables['dbConnectAdmin'] .= '<td><div class="cross"></div></td>' . '<td class="error">Unable to connect to database (user: '******'dmsname'] . ')</td>'; $this->database_check = 'cross'; $this->temp_variables['dbConnectAdmin'] .= sprintf($html, 'cross', 'class="error"', 'Unable to connect to database (user: '******'dmsname'] . ')'); } else { $this->temp_variables['dbConnectAdmin'] .= sprintf($html, 'tick', '', 'Database connectivity successful (user: '******'dmsname'] . ')'); } // make db connection - user $loaded = $this->_dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); // if we can log in to the database, check access // TODO check write access? if ($loaded) { $this->temp_variables['dbConnectUser'] .= sprintf($html, 'tick', '', 'Database connectivity successful (user: '******'dmsusername'] . ')'); $qresult = $this->_dbhandler->query('SELECT COUNT(id) FROM documents'); if (!$qresult) { $this->temp_variables['dbPrivileges'] .= '<td><div class="cross" style="float:left;"></div></td>' . '<td class="error">' . 'Unable to do a basic database query<br/>Error: ' . $this->_dbhandler->getLastError() . '</td>'; $this->database_check = 'cross'; $this->temp_variables['dbPrivileges'] .= sprintf($html, 'cross', 'class="error"', 'Unable to do a basic database query<br/>Error: ' . $this->_dbhandler->getLastError()); $this->privileges_check = 'cross'; } else { $this->temp_variables['dbPrivileges'] .= sprintf($html, 'tick', '', 'Basic database query successful'); } // check transaction support $sTable = 'system_settings'; $this->_dbhandler->startTransaction(); $this->_dbhandler->query('INSERT INTO ' . $sTable . ' (name, value) VALUES ("transactionTest", "1")'); $this->_dbhandler->rollback(); $res = $this->_dbhandler->query("SELECT id FROM {$sTable} WHERE name = 'transactionTest' LIMIT 1"); if (!$res) { $this->temp_variables['dbTransaction'] = '<td><div class="cross_orange" style="float:left;"></div></td>' . '<span class="error">Transaction support not available in database</span></td>'; $this->database_check = 'cross'; $this->temp_variables['dbTransaction'] .= sprintf($html, 'cross_orange', 'class="orange"', 'Transaction support not available in database'); } else { $this->temp_variables['dbTransaction'] .= sprintf($html, 'tick', '', 'Database has transaction support'); } $this->_dbhandler->query('DELETE FROM ' . $sTable . ' WHERE name = "transactionTest"'); } else { $this->temp_variables['dbConnectUser'] .= sprintf($html, 'cross', 'class="error"', 'Unable to connect to database (user: '******'dmsusername'] . ')'); } }
/** * Load a file * * @param string $file * @param string|boolean $encoding * @param bool $noBasePath * * @return LaravelExcelReader */ public function load($file, $encoding = false, $noBasePath = false) { // init the loading $this->_init($file, $encoding, $noBasePath); // Only fetch selected sheets if necessary if ($this->sheetsSelected()) { $this->reader->setLoadSheetsOnly($this->selectedSheets); } // Load the file $this->excel = $this->reader->load($this->file); // Return itself return $this; }
/** Get the data from the solr instance * @access public * @return boolean */ public function getData() { if (!$this->getCache()->test($this->getKey())) { $mlt = $this->getSolr(); $mlt->setFields(array('objecttype', 'broadperiod', 'description', 'notes')); $mlt->setQuery($this->getQuery()); $solrResponse = $mlt->executeQuery(); $this->getCache()->save($solrResponse); } else { $solrResponse = $this->_cache->load($this->getKey()); } return $solrResponse; }