public function save($data) { $component = $data['component']; $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component); $component = JString::strtolower(JString::trim($component)); unset($data['component']); $config = Komento::getTable('Configs'); $config->load($component); $config->component = $component; $json = Komento::getJSON(); $config->params = $json->encode($data); $result = $config->store(); // Save it if (!$result) { return false; } return true; }
public function getAclObject( $cid = 0, $type = 'usergroup', $component = 'com_content' ) { $sql = Komento::getSql(); $sql->select( '#__komento_acl' ) ->column( 'rules' ) ->where( 'cid', $cid ) ->where( 'type', $type ) ->where( 'component', $component ) ->order( 'id' ); $result = $sql->loadResult(); if( empty( $result ) ) { return false; } $json = Komento::getJSON(); $result = $json->decode( $result ); return $result; }
public static function getEmptySet( $flat = false ) { static $acl = null; if( empty( $acl ) ) { $rulesFile = KOMENTO_ADMIN_ROOT . DIRECTORY_SEPARATOR . 'acl.json'; if( !JFile::exists( $rulesFile ) ) { return false; } $contents = JFile::read( $rulesFile ); $json = Komento::getJSON(); $acl = $json->decode( $contents ); } if( $flat === false ) { return $acl; } $data = new stdClass(); foreach( $acl as $section => $rules ) { foreach( $rules as $key => $value ) { $data->$key = $value; } } return $data; }
public function save($data) { $component = $data['target_component']; unset($data['target_component']); $cid = $data['target_id']; unset($data['target_id']); $type = $data['target_type']; unset($data['target_type']); Komento::import('helper', 'acl'); $defaultset = KomentoACLHelper::getEmptySet(true); foreach ($defaultset as $key => $value) { if (isset($data[$key])) { $defaultset->{$key} = $data[$key] ? true : false; } } $table = Komento::getTable('Acl'); $table->compositeLoad($cid, $type, $component); $json = Komento::getJSON(); $table->rules = $json->encode($defaultset); return $table->store(); }