Example #1
0
 /**
  * 写入
  *
  * @access public
  * @param $key
  * @param $value
  * @param $life
  * @return int
  */
 public function setCache($key, $value, $life = 0)
 {
     $this->_conndb();
     $this->_setParam($key, $value, $life);
     $data = array('key' => $this->_key, 'value' => $this->_value, 'life' => $this->_life + time());
     return $this->_dblink->save(array('data' => $data, 'replace' => true));
 }
Example #2
0
 /**
  * updates the whole setting section
  * firsts it renders the input names of the submitted form
  * into database fields
  * it also merge the current settings or update the submitted settings into
  * db .
  * it also use serialization for each fields
  *
  * @param boolean $blogApi
  */
 public static function update($blogApi = false)
 {
     /**
      * set Self::$settings with Applum::find(1)
      */
     self::setSettings();
     /**
      * renders submitted form inputs
      * which is compatible with the database structure
      *
      * IMPORTANT : I have to fine a better place for this one
      */
     DataFormatter::render($blogApi);
     /**
      * updates uploaded file info into database
      */
     AFile::updateFile();
     /**
      * for the sake of serialization there is some boundaries . we can`t
      * change new settings with the current one , we have to maintain the untouched
      * settings and update the touched ones .
      */
     self::use_submitted_info_and_leave_untouch_settings();
     self::$settings->save();
 }
Example #3
0
 /**
  * validate
  *
  * @param  mixed   $identifier
  * @return boolean
  */
 public function validate($identifier = null)
 {
     // No identifier
     if (!$identifier) {
         throw new \InvalidArgumentException('identifier is a required argument');
     }
     // Current attempts
     $attempts = $this->storage->increment($identifier);
     // No attempts
     if (!$attempts) {
         $this->storage->save($identifier, 1, $this->options['timespan']);
         // Logged
     } elseif ($attempts == $this->options['logged']) {
         // Set expiration to zero (perm ban)
         $this->storage->update($identifier, $attempts, 0);
         // Log
         $this->logger->log('warning', $identifier . ' exceeded the number of allowed requests');
         return false;
         // Banned
     } elseif ($attempts >= $this->options['banned']) {
         return false;
     }
     // Valid
     return true;
 }
Example #4
0
 /**
  * Send an SMS
  *
  * @param object $model 
  * @param mixed $To Number or array of To, Message, and From
  * @param string $Message 
  * @param string $From 
  * @return boolean True if sent, false otherwise
  * @access public
  */
 function sendSms(&$model, $To, $Body = null, $From = null)
 {
     if (!$this->_setupModel($model)) {
         return false;
     }
     if (is_array($To)) {
         if (isset($To['From'])) {
             $From = $To['From'];
         }
         if (isset($To['Body'])) {
             $Body = $To['Body'];
         }
         if (isset($To['To'])) {
             $To = $To['To'];
         }
     }
     if (is_array($To)) {
         return false;
     }
     if (empty($From)) {
         $From = $this->settings[$model->alias]['From'];
     }
     if (empty($To) || empty($Body) || empty($From)) {
         return false;
     }
     return $this->_Text->save(compact('To', 'Body', 'From'));
 }
Example #5
0
 /**
  * Entity update.
  * 
  * @helper Model update
  * @param array $data
  * @return \Veer\Services\Administration\Elements\Entity
  */
 public function update($data)
 {
     if ($this->entity instanceof $this->className && !empty($data)) {
         $this->entity->fill($this->prepareData($data));
         $this->entity->save();
         event('veer.message.center', trans('veeradmin.' . $this->type . '.update'));
     }
     return $this;
 }
 /**
  * Step callback
  */
 public function callback()
 {
     $saved = $this->fields->save();
     // No need to fetch api again if fields  updated
     // Once all the fields are saved, let's query our image api with the saved category
     $site_industry = isset($saved['wpem_site_industry']) ? $saved['wpem_site_industry'] : false;
     $site_type = isset($saved['wpem_site_type']) ? $saved['wpem_site_type'] : false;
     if ($site_industry && 'store' !== $site_type) {
         $this->image_api->get_images_by_cat($site_industry);
     }
 }
Example #7
0
 /**
  * 亿起发订单处理,本地存入数据库,调用亿起发接口
  * @access private
  * @param array $order 订单数据
  * @param array $refer 订单来源
  * @return boolean
  */
 private function emar($order, $refer)
 {
     //存入亿起发订单记录
     $data = array('order_id' => $order['order_id'], 'src' => 'emar', 'createtime' => $order['createtime'], 'order_cost' => $order['cost_item'], 'url' => $refer['refer_url'] . '', 'status' => '0', 'params' => array('cid' => $refer['cid'], 'wi' => $refer['wi']));
     //本地存入数据库
     $rtn = $this->mdlTpo->save($data);
     //调用亿起发接口
     $url = 'http://o.yiqifa.com/servlet/handleCpsIn?cid=' . $refer['cid'] . '&wi=' . $refer['wi'] . '&on=' . $order['order_id'] . '&ta=1&pp=' . $order['cost_item'] . '&sd=' . date('Y-m-d H:i:s', $order['createtime']) . '&encoding=UTF-8';
     $rs = file_get_contents($url);
     return $rtn;
 }
Example #8
0
 /**
  * Cached transformation a given XML string using
  * the registered PHP callbacks for overloaded tags.
  *
  * @param  string
  * @param  string
  * @return string
  * @access public
  */
 function transform($xml, $cacheID = '')
 {
     $cacheID = $cacheID != '' ? $cacheID : md5($xml);
     $cachedResult = $this->_cache->get($cacheID, 'XML_Transformer');
     if ($cachedResult !== FALSE) {
         return $cachedResult;
     }
     $result = parent::transform($xml);
     $this->_cache->save($result, $cacheID, 'XML_Transformer');
     return $result;
 }
Example #9
0
 /**
  * Insert given mail data to database
  * 
  * @param Request $request Request object
  * 
  * @return type
  */
 public function insertMails($request)
 {
     $data = $request->all();
     foreach ($data as $field => $value) {
         if (!empty($value)) {
             $this->mailer->{$field} = $value;
         }
     }
     $this->mailer->referer = $request->server('HTTP_HOST');
     $this->mailer->save();
     return $this->getOutput(IsMailer::get());
 }
Example #10
0
 /**
  * Class Constructor
  * Cache all cron jobs and save into memory so we can call
  * them at a later point in time when needed
  *
  */
 public function __construct()
 {
     $this->_oCache = Phpfox::getLib('cache');
     $sCacheId = $this->_oCache->set('cron');
     if (!($this->_aCrons = $this->_oCache->get($sCacheId))) {
         $aRows = Phpfox_Database::instance()->select('cron.*')->from(Phpfox::getT('cron'), 'cron')->join(Phpfox::getT('product'), 'product', 'product.product_id = cron.product_id AND product.is_active = 1')->join(Phpfox::getT('module'), 'm', 'm.module_id = cron.module_id AND m.is_active = 1')->where('cron.is_active = 1')->execute('getSlaveRows');
         foreach ($aRows as $aRow) {
             $this->_aCrons[$aRow['cron_id']] = $aRow;
         }
         // Save cron jobs into cache
         $this->_oCache->save($sCacheId, $this->_aCrons);
     }
     ($sPlugin = Phpfox_Plugin::get('cron_construct')) ? eval($sPlugin) : false;
 }
Example #11
0
 /**
  * get() is the main method of the phpOpenTracker API. You pass it an
  * array, which defines the type of information you want. Please refer to
  * the chapter 'API Reference' of the phpOpenTracker Manual for detailed
  * information and examples.
  *
  * @param  array   $parameters
  * @return mixed
  * @access public
  */
 function &get($parameters)
 {
     if (!$this->_parseParameters($parameters)) {
         return false;
     }
     $doCache = false;
     if (is_object($this->cache)) {
         ksort($parameters);
         $cacheID = md5(serialize($parameters));
         $cachedResult = $this->cache->get($cacheID, 'phpOpenTracker');
         if ($cachedResult != NULL) {
             return unserialize($cachedResult);
         }
         if ($parameters['start'] != false && $parameters['start'] < time() && $parameters['end'] != false && $parameters['end'] < time()) {
             $doCache = true;
         }
     }
     if (isset($this->apiCalls['get'][$parameters['api_call']])) {
         $result = $this->apiCalls['get'][$parameters['api_call']]->run($parameters);
     } else {
         return phpOpenTracker::handleError(sprintf('Unknown API Call %s.', $parameters['api_call']));
     }
     if ($doCache && $result !== false) {
         $this->cache->save(serialize($result), $cacheID, 'phpOpenTracker');
     }
     return $result;
 }
Example #12
0
 /**
  * oxActions::start() test case
  * Create a new promo action and check if they are active until our setted date.
  * Save the date into the db and read it with the id of the promo out.
  *
  * @return null
  */
 public function testStart()
 {
     oxTestModules::addFunction('oxUtilsDate', 'getTime', '{return ' . time() . ';}');
     $this->_oPromo->oxactions__oxactiveto = new oxField('');
     $this->_oPromo->oxactions__oxactivefrom = new oxField('');
     $this->_oPromo->save();
     $id = $this->_oPromo->getId();
     $this->_oPromo = oxNew('oxActions');
     $this->_oPromo->load($id);
     $this->assertEquals('0000-00-00 00:00:00', $this->_oPromo->oxactions__oxactiveto->value);
     $this->assertEquals('0000-00-00 00:00:00', $this->_oPromo->oxactions__oxactivefrom->value);
     $this->_oPromo->start();
     $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__oxactivefrom->value);
     $this->assertEquals('0000-00-00 00:00:00', $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__oxactivefrom->value);
     $this->assertEquals('0000-00-00 00:00:00', $this->_oPromo->oxactions__oxactiveto->value);
     $this->_oPromo->oxactions__oxactiveto = new oxField(date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime() + 10));
     $sTo = $this->_oPromo->oxactions__oxactiveto->value;
     $this->_oPromo->save();
     $id = $this->_oPromo->getId();
     $this->_oPromo = oxNew('oxActions');
     $this->_oPromo->load($id);
     $this->assertEquals($sTo, $this->_oPromo->oxactions__oxactiveto->value);
     $this->_oPromo->start();
     $id = $this->_oPromo->getId();
     $this->_oPromo = oxNew('oxActions');
     $this->_oPromo->load($id);
     $this->assertEquals($sTo, $this->_oPromo->oxactions__oxactiveto->value);
 }
 /**
  * @param object $participation
  * @return void
  * @throws \Exception
  */
 public function sendEmail($participation)
 {
     $email = $participation->getEmail();
     $emailDomain = trim(strtolower(preg_replace('/^[^@]+@/', '', $email)));
     $participation->setEmailDomain($emailDomain);
     $participation->save();
     $confirmationLink = $this->createConfirmationLink($participation->getConfirmationCode());
     $parameters = array('confirmationLink' => $confirmationLink, 'participationId' => $participation->getId());
     $emailDocumentPath = Plugin::getConfig()->get('emailDocumentPath');
     $emailDocument = DocumentModel::getByPath($emailDocumentPath);
     if (!$emailDocument instanceof EmailDocument) {
         throw new \Exception("Error: emailDocumentPath [{$emailDocumentPath}] " . "is not a valid email document.");
     }
     $mail = new Mail();
     $mail->addTo($email);
     if ($this->getSubject()) {
         $mail->setSubject($this->getSubject());
     }
     $mail->setDocument($emailDocumentPath);
     $mail->setParams($parameters);
     $mail->send();
     $note = new Note();
     $note->setElement($participation);
     $note->setDate(time());
     $note->setType("confirmation");
     $note->setTitle("Email sent");
     $note->addData("email", "text", $email);
     $note->setUser(0);
     $note->save();
 }
Example #14
0
 /**
  * save a model without massive assignment
  *
  * @param array $data
  * @return bool
  */
 public function saveModel(array $data)
 {
     foreach ($data as $k => $v) {
         $this->model->{$k} = $v;
     }
     return $this->model->save();
 }
Example #15
0
 /**
  * Save department.
  *
  * @param object $department
  */
 public function save($department)
 {
     $department->set(['name' => Request::$post['name']]);
     if ($department->save()) {
         Request::redirectTo('/admin/departments');
     }
 }
Example #16
0
 /**
  * Admin edit
  *
  * @param integer $id
  * @return void
  * @access public
  */
 public function admin_edit($id = null)
 {
     // Protect against administrator edit
     if ($id == null || $id < 4) {
         $this->Session->setFlash(__('Invalid request.'), 'flash_message_error');
         $this->redirect(array('action' => 'index'));
     }
     $errors = null;
     if (!empty($this->request->data)) {
         $this->request->data['Aro']['model'] = '';
         // update alias with user data
         if ($this->request->data['Aro']['foreign_key'] != '') {
             $this->request->data['Aro']['model'] = 'User';
             $this->request->data['Aro']['alias'] = $this->User->field('Name', array('id' => $this->request->data['Aro']['foreign_key']));
         }
         $this->Node->recursive = -1;
         $this->request->data = array_merge($this->Node->read(null, $id), $this->request->data);
         // alias must be unique
         $this->Node->validate = array('alias' => array('rule' => 'isUnique', 'message' => __('Group / User name must be unique!!')));
         if ($this->Node->save($this->request->data)) {
             $this->Session->setFlash(__('Saved with success.'), 'flash_message_info');
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('Could not be saved. Please, try again.'), 'flash_message_error');
         }
     }
     if (empty($this->request->data)) {
         $this->request->data = $this->Node->read(null, $id);
     }
     $parents[0] = "[ " . __('Root') . " ]";
     $nodelist = $this->Node->generateTreeList(null, '{n}.Aro.id', '{n}.Aro.alias', ' - ', '-1');
     $acolist = $this->Acl->Aco->generateTreeList(null, '{n}.Aco.id', '{n}.Aco.alias', ' - ', '-1');
     $acoAccessList = $this->Acl->Aco->generateTreeList(null, '{n}.Aco.id', '{n}.Aco.alias', '', '-1');
     $acoAliasList = $acoAccessList;
     foreach ($acoAccessList as $key => $value) {
         $alias = "";
         $path = $this->Acl->Aco->getPath($key);
         foreach ($path as $pathAlias) {
             if ($alias != '') {
                 $alias = $alias . '/';
             }
             $alias = $alias . $pathAlias['Aco']['alias'];
         }
         $acoAliasList[$key] = $alias;
         $acoAccessList[$key] = $this->Acl->check($this->request->data['Aro']['alias'], $alias);
         #value
     }
     if ($nodelist) {
         foreach ($nodelist as $key => $value) {
             $parents[$key] = $value;
         }
     }
     $foreignKeys = array();
     // if node is group type ( without foreignKey ) do no show available users
     if ($this->Node->field('foreign_key')) {
         $usersOnAro = $this->Node->find('list', array('fields' => array('Aro.foreign_key'), 'conditions' => array('Aro.foreign_key <>' => null, 'Aro.id <>' => $id)));
         $foreignKeys = $this->User->find('list', array('conditions' => array('User.active' => '1', 'NOT' => array('User.id' => $usersOnAro))));
     }
     $this->set(compact('parents', 'acolist', 'foreignKeys', 'acoAccessList', 'acoAliasList'));
 }
Example #17
0
 /**
  * This method save session data. If old session exists,
  * save it data and send cookie. If no old session,
  * generate unique session ID, define session type, save
  * new session data and send cookie.
  * If no old session and sessionStorage empty do nothing.
  *
  * @return bool     True on success, false on failure.
  * @throws RuntimeException if can't save session.
  */
 public function save()
 {
     // run garbage collector
     $this->runGarbageCollector();
     // if current session not newly
     if ($this->isSavedSession()) {
         // get full session ID
         $fullSessID = $this->getFullSessID();
         // save session
         if ($this->adapter->save($this->repository, $fullSessID, $this->sessStorage)) {
             return setcookie($this->cookieName, $fullSessID, time() + (int) $this->settings[$this->currentSessType]);
         } else {
             throw new RuntimeException("Can't save session.");
         }
     }
     // if current session is newly
     if (!empty($this->sessStorage)) {
         // define session type
         $sessionType = $this->currentSessType ? $this->currentSessType : 'short';
         // generate new session ID and get full session ID
         $fullSessID = $this->generateSessID() . $sessionType;
         // save session
         if ($this->adapter->save($this->repository, $fullSessID, $this->sessStorage)) {
             return setcookie($this->cookieName, $fullSessID, time() + (int) $this->settings[$sessionType]);
         } else {
             throw new RuntimeException("Can't save session.");
         }
     }
 }
Example #18
0
 /**
  * Create or update a record to
  * DB from POST data or input array of data
  *
  * @param array $dataArray an array holding data to save. If empty, $_POST is used
  * @return integer id of created or updated record
  */
 public function save($dataArray = null)
 {
     // get required tools
     jimport('joomla.database.table');
     $this->_data = JTable::getInstance($this->_defaultTable, 'Sh404sefTable');
     $post = is_null($dataArray) ? JRequest::get('post') : $dataArray;
     // use table save method
     try {
         $status = $this->_data->save($post);
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         $this->_data->setError($e->getMessage());
         $status = false;
     }
     // report error
     if (!$status) {
         JFactory::getApplication()->enqueuemessage($this->_data->getError());
         return 0;
     }
     // if success, fetch last insert id and return that
     $tableDb = $this->_data->getDBO();
     $keyName = $this->_data->getKeyName();
     $id = empty($post[$keyName]) ? 0 : intval($post[$keyName]);
     $savedId = empty($id) ? $tableDb->insertid() : $id;
     return $savedId;
 }
Example #19
0
 /**
  * {@inheritDoc}
  */
 public function clearAllAuthorizationStates()
 {
     $this->user->__set($this->stateKey, '');
     $this->user->save();
     // allow chaining
     return $this;
 }
Example #20
0
 /**
  * Gets definitions for the specified word in the specified database.
  *
  * @param string $word
  * @param string $database
  * 
  * @return mixed Array of definitions if sucessful, else PEAR_Error
  */
 function define($word, $database = '*')
 {
     if ($this->caching) {
         if ($defines = $this->cache->get($word, 'Net_Dict_Defs')) {
             return $defines;
         }
     }
     if (!is_object($_socket)) {
         $this->connect();
     }
     $resp = $this->_sendCmd("DEFINE {$database} '{$word}'");
     if (PEAR::isError($resp)) {
         return $resp;
     }
     list($num) = explode(' ', $resp['text'], 2);
     for ($i = 0; $i < $num; $i++) {
         $resp = $this->_socket->readLine();
         preg_match("/(\\d{3})\\s+?\"(.+)?\"\\s+?(\\S+)\\s+?\"(.+)?\"/", $resp, $matches);
         $defines[$i]['response'] = $resp;
         $defines[$i]['word'] = $matches[2];
         $defines[$i]['database'] = $matches[3];
         $defines[$i]['description'] = $matches[4];
         $resp = $this->_getMultiline();
         $defines[$i]['definition'] = $resp['text'];
     }
     $this->readLine();
     /* discard status */
     if ($this->caching) {
         $this->cache->save($word, $defines, 0, 'Net_Dict_Defs');
     }
     return $defines;
 }
Example #21
0
 /**
  * Save status.
  *
  * @param object $status
  */
 public function save($status)
 {
     $status->set(['name' => Request::$post['name']]);
     if ($status->save()) {
         Request::redirectTo('/admin/statuses');
     }
 }
Example #22
0
 /**
  * handle ajax requests
  */
 protected function handleAjax()
 {
     // delete socialmedia links
     if (\Input::get('act') == 'delSocialmediaLink' && \Input::post('type')) {
         if (FE_USER_LOGGED_IN) {
             $arrSocialmediaLinks = deserialize($this->loggedInUser->socialmediaLinks);
             if (array_search(\Input::post('type'), $arrSocialmediaLinks) !== false) {
                 $key = array_search(\Input::post('type'), $arrSocialmediaLinks);
                 unset($arrSocialmediaLinks[$key]);
             }
             $this->loggedInUser->socialmediaLinks = serialize(array_values($arrSocialmediaLinks));
             $this->loggedInUser->save();
             $this->log('A new version of tl_member ID ' . $this->loggedInUser->id . ' has been created', __METHOD__, TL_GENERAL);
         }
     }
     // toggle visibility (publish or unpublish)
     if (\Input::get('act') == 'toggleVisibility' && \Input::get('id')) {
         if (FE_USER_LOGGED_IN) {
             $objComment = \CommentsModel::findByPk(\Input::get('id'));
             if ($objComment !== NULL) {
                 if ($this->loggedInUser->id == $objComment->parent) {
                     $isPublished = $objComment->published ? 0 : 1;
                     $objComment->published = $isPublished;
                     $objComment->save();
                     $this->log('A new version of tl_comments ID ' . $objComment->id . ' has been created', __METHOD__, TL_GENERAL);
                     $strReturn = $isPublished == 0 ? 'invisible' : 'visible';
                     echo $strReturn;
                 }
             }
         }
     }
     exit;
 }
Example #23
0
 /**
  * Admin edit
  *
  * @param integer $id
  * @return void
  * @access public
  */
 public function admin_edit($id = null)
 {
     if ($id == null || $id < 3) {
         $this->Session->setFlash(__('Invalid request.'), 'flash_message_error');
         $this->redirect(array('action' => 'index'));
     }
     if (!empty($this->request->data)) {
         if ($this->Node->save($this->request->data)) {
             $this->Session->setFlash(__('Saved with success.'), 'flash_message_info');
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('Could not be saved. Please, try again.'), 'flash_message_error');
         }
     } else {
         $this->request->data = $this->Node->read(null, $id);
     }
     $parents[0] = "[ No Parent ]";
     $nodelist = $this->Node->generateTreeList(null, '{n}.Aco.id', '{n}.Aco.alias', ' - ', '-1');
     if ($nodelist) {
         foreach ($nodelist as $key => $value) {
             $parents[$key] = $value;
         }
     }
     $this->set(compact('parents'));
 }
Example #24
0
 /**
  * Method to save the activity to the database
  *
  * @return    boolean    True on success, False on error
  */
 protected function save()
 {
     // Set state if not set
     if (!isset($this->activity_data['state'])) {
         $this->activity_data['state'] = 1;
     }
     // Set access if not set
     if (!isset($this->activity_data['access'])) {
         $this->activity_data['access'] = (int) JFactory::getConfig()->get('access');
     }
     // Save the item
     if (!$this->item_model->save($this->item_data)) {
         return false;
     }
     // Fill in activity id if not set
     if (!isset($this->activity_data['item_id']) || empty($this->activity_data['item_id'])) {
         $item_id = $this->item_model->getState($this->item_model->getName() . '.id');
         $this->activity_data['item_id'] = $item_id;
     }
     // Fill in activity type id if not set
     if (!isset($this->activity_data['type_id']) || empty($this->activity_data['type_id'])) {
         $type_id = $this->item_model->getState($this->item_model->getName() . '.type');
         $this->activity_data['type_id'] = $type_id;
     }
     // Fill in activity days since epoch if not set
     if (!isset($this->activity_data['created_day']) || empty($this->activity_data['created_day'])) {
         $this->activity_data['created_day'] = floor(time() / 86400);
     }
     // Save the activity
     if (!$this->activity_model->save($this->activity_data)) {
         return false;
     }
     return true;
 }
Example #25
0
	/**
	 * Store the data to a file by id and group
	 *
	 * @param   string  $id     The cache data id.
	 * @param   string  $group  The cache data group.
	 * @param   string  $data   The data to store in cache.
	 *
	 * @return  boolean  True on success, false otherwise
	 *
	 * @since   11.1
	 */
	public function store($id, $group, $data)
	{
		$dir = $this->_root . '/' . $group;

		// If the folder doesn't exist try to create it
		if (!is_dir($dir)) {
			// Make sure the index file is there
			$indexFile = $dir.'/index.html';
			@mkdir($dir) && file_put_contents($indexFile, '<!DOCTYPE html><title></title>');
		}

		// Make sure the folder exists
		if (!is_dir($dir)) {
			return false;
		}

		self::$CacheLiteInstance->setOption('cacheDir', $this->_root . '/' . $group . '/');
		$this->_getCacheId($id, $group);
		$success = self::$CacheLiteInstance->save($data, $this->rawname, $group);

		if ($success == true) {
			return $success;
		}
		else {
			return false;
		}
	}
 /**
  * Add bulk actions
  *
  * @return array
  **/
 public function bulk_actions_save()
 {
     $wp_list_table = _get_list_table('WP_Plugins_List_Table');
     $action = $wp_list_table->current_action();
     $sendback = 'plugins.php';
     switch ($action) {
         case 'categorize':
             $plugins = isset($_POST['checked']) ? (array) $_POST['checked'] : array();
             $category = isset($_POST['plugin_category_select']) ? (string) $_POST['plugin_category_select'] : false;
             if (!empty($plugins) && $category) {
                 $added = array();
                 foreach ($plugins as $plugin) {
                     $this->plugin->save(array('category' => $category, 'plugin' => $plugin));
                     $added[] = urlencode($plugin);
                 }
                 $sendback = add_query_arg(array('category' => $category, 'categories-added' => true, 'added' => implode(',', $added)), $sendback);
             }
             wp_redirect($sendback);
             exit;
             return;
             break;
         default:
             return;
     }
 }
Example #27
0
 protected function setUp()
 {
     parent::setUp();
     // Create an admin user, log in and enable test blocks.
     $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'access administration pages'));
     $this->drupalLogin($this->adminUser);
     // Create additional users to test caching modes.
     $this->normalUser = $this->drupalCreateUser();
     $this->normalUserAlt = $this->drupalCreateUser();
     // Sync the roles, since drupalCreateUser() creates separate roles for
     // the same permission sets.
     $this->normalUserAlt->roles = $this->normalUser->getRoles();
     $this->normalUserAlt->save();
     // Enable our test block.
     $this->block = $this->drupalPlaceBlock('test_cache');
 }
 /**
  * Run before a model is deleted, used to do a soft delete when needed.
  *
  * @param object $Model Model about to be deleted
  * @param boolean $cascade If true records that depend on this record will also be deleted
  * @return boolean Set to true to continue with delete, false otherwise
  * @access public
  */
 function beforeDelete(&$Model, $cascade = true)
 {
     if ($this->__settings[$Model->alias]['delete'] && $Model->hasField($this->__settings[$Model->alias]['field'])) {
         $attributes = $this->__settings[$Model->alias];
         $id = $Model->id;
         $data = array($Model->alias => array($attributes['field'] => 1));
         if (isset($attributes['field_date']) && $Model->hasField($attributes['field_date'])) {
             $data[$Model->alias][$attributes['field_date']] = date('Y-m-d H:i:s');
         }
         foreach (array_merge(array_keys($data[$Model->alias]), array('field', 'field_date', 'find', 'delete')) as $field) {
             unset($attributes[$field]);
         }
         if (!empty($attributes)) {
             $data[$Model->alias] = array_merge($data[$Model->alias], $attributes);
         }
         $Model->id = $id;
         $deleted = $Model->save($data, false, array_keys($data[$Model->alias]));
         if ($deleted && $cascade) {
             $Model->_deleteDependent($id, $cascade);
             $Model->_deleteLinks($id);
         }
         return false;
     }
     return true;
 }
 /**
  * Remove user from the storage container
  *
  * @param string Username
  */
 function removeUser($username)
 {
     $res = $this->pwfile->delUser($username);
     if ($res === true) {
         return $this->pwfile->save();
     }
     return $res;
 }
 /**
  * show()
  *
  * @access public
  * @return void
  */
 function show()
 {
     $sBuff = parent::get();
     if (0 < $this->_iHtmlCacheExpire) {
         $this->_objCache->save($this->_sCacheId, $sBuff, $this->_iHtmlCacheExpire, $this->_sCacheGrp);
     }
     $this->_show($sBuff);
 }