function processSave($id = 0, $post = null) { //save aclparam and core param in individual columns $id = JRequest::getVar('id', $id); $data = array(); if ($post === null) { $post = JRequest::get('post'); } $model = $this->getModel(); // Get the complete INI string of params $param = new XiptParameter(); $post['coreparams']['core_display_message'] = base64_encode($post['coreparams']['core_display_message']); $param->loadArray($post['coreparams'], 'xipt_coreparams'); $data['coreparams'] = $param->toString('XiptINI', 'xipt_coreparams'); $data['aclname'] = $post['aclname']; $data['rulename'] = $post['rulename']; $data['published'] = $post['published']; $aclObject = XiptAclFactory::getAclObject($data['aclname']); $data['aclparams'] = $aclObject->collectParamsFromPost($post); // Save it // XITODO : clean it if (!($info['id'] = $model->save($data, $id))) { $info['msg'] = XiptText::_('ERROR_IN_SAVING_RULE'); } else { $info['msg'] = XiptText::_('RULE_SAVED'); } return $info; }
/** * Save the configuration to the config file * * @return boolean True on success false on failure. **/ function saveParams($data, $id, $what = 'params') { XiptError::assert($id, XiptText::_("ID {$id} IS_NOT_VALID"), XiptError::ERROR); if (empty($data) || !is_array($data)) { return false; } //We want to handle only JS Configuration from this function //Everything else should be handled by generic parent function if ($what != 'params') { parent::saveParams($data, $id, $what); return; } // XITODO : move this to controller unset($data[JUtility::getToken()]); unset($data['option']); unset($data['task']); unset($data['view']); unset($data['id']); //XITODO : bind params $param = new XiptParameter(); $param->loadArray($data); $params = $param->toString('XiptINI'); return $this->save(array($what => $params), $id); }
function loadParams($id, $what = '') { $record = $this->loadRecords(0); $xmlPath = XIPT_FRONT_PATH_ASSETS . DS . 'xml' . DS . JString::strtolower($this->getName() . ".{$what}.xml"); $iniPath = XIPT_FRONT_PATH_ASSETS . DS . 'ini' . DS . JString::strtolower($this->getName() . ".{$what}.ini"); $iniData = JFile::read($iniPath); XiptError::assert(JFile::exists($xmlPath), sprintf(XiptText::_("FILE_DOES_NOT_EXIST"), $xmlPath), XiptError::ERROR); $config = new XiptParameter($iniData, $xmlPath); if (isset($record[$id])) { $config->bind($record[$id]->{$what}); } return $config; }
function collectParamsFromPost($postdata) { // it is not necessary the each rule will have acl params // so check it, and return empty ini string if not exists if (!isset($postdata['aclparams'])) { return "\n\n"; } $param = new XiptParameter(); $param->loadArray($postdata['aclparams']); return $param->toString('XiptINI'); }
function _saveWatermark($id) { $model = $this->getModel(); //Collect Newly saved data $newData = $model->loadRecords(0); $newData = $newData[$id]; $config = new XiptParameter('', ''); $config->bind($newData->watermarkparams); // if enable water mark is false then no need to create watermark if (!$config->get('enableWaterMark')) { return false; } //no change condition i.e if type of watermark is image // but no image is selected then return if (empty($_FILES['watermarkparams']['tmp_name']['xiImage']) && $config->get('typeofwatermark', '0') == '1') { return false; } // generate watermark image //XITODO : improve nomenclature $imageGenerator = new XiptLibImage($config); $storage = PROFILETYPE_AVATAR_STORAGE_PATH; $imageName = 'watermark_' . $id; // create watermark according to the type of watermark selected if ($config->get('typeofwatermark', '0') == '1') { $filename = $imageGenerator->createImageWatermark($storage, $imageName); } else { $filename = $imageGenerator->genImage($storage, $imageName); } //XITODO : assert on filename $image = PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH . DS . $filename; $data = array('watermark' => XiptHelperUtils::getUrlpathFromFilePath($image)); $this->generateThumbnail($imageName, $filename, $storage, $newData, $config); // now save model $model->save($data, $id); return $image; }
function _migration460() { $ver = intval(self::getXiptVersion()); //echo $ver; if ($ver > 460) { return false; } echo $ver; $db = JFactory::getDBO(); $query = 'SELECT `id`, `coreparams` FROM `#__xipt_aclrules`'; $db->setQuery($query); $aclrules = $db->loadObjectList(); foreach ($aclrules as $data) { $registry = new XiptParameter(); $registry->loadINI($data->coreparams); $params = $registry->toArray(); $params['core_display_message'] = base64_encode($params['core_display_message']); $registry->loadArray($params); $iniParamData = $registry->toString('XiptINI'); $query = 'UPDATE `#__xipt_aclrules`' . ' SET `coreparams`=' . $db->Quote($iniParamData) . 'WHERE ' . $db->nameQuote('id') . '=' . $db->Quote($data->id) . ''; $db->setQuery($query); $db->query(); } return true; }
<img src="<?php echo JURI::root() . XiptHelperUtils::getUrlpathFromFilePath($field->avatar); ?> " width="64" height="64" border="0" alt="<?php echo $field->avatar; ?> " /> </td> <td align="center" id="watermark<?php echo $field->id; ?> "> <?php $wm = $field->watermarkparams; $wmparams = new XiptParameter($wm, ''); if ($wmparams->get('enableWaterMark', 0)) { ?> <img src="<?php echo JURI::root() . XiptHelperUtils::getUrlpathFromFilePath($field->watermark); ?> " border="0" alt="<?php echo $field->watermark; ?> " /> <?php } ?> </td>
function saveValueinJSConfig($setValue = 0) { CFactory::load('helpers', 'string'); $config = JTable::getInstance('configuration', 'CommunityTable'); $config->load('config'); $params = new XiptParameter($config->params); $params->set('profile_multiprofile', $setValue); $config->params = $params->toString(); if (!$config->store()) { return false; } return true; }