本文整理匯總了PHP中JAccessRules::mergeAction方法的典型用法代碼示例。如果您正苦於以下問題:PHP JAccessRules::mergeAction方法的具體用法?PHP JAccessRules::mergeAction怎麽用?PHP JAccessRules::mergeAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JAccessRules
的用法示例。
在下文中一共展示了JAccessRules::mergeAction方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testMergeRule
/**
* Tests the JAccessRules::mergeAction method.
*
* @return void
*
* @since 11.1
* @covers JAccessRules::mergeAction
*/
public function testMergeRule()
{
$identities = array(-42 => 1, 2 => 1, 3 => 0);
$result = array('edit' => array(-42 => 1, 2 => 1, 3 => 0));
// Construct and empty JAccessRules.
$rules = new JAccessRules('');
$rules->mergeAction('edit', $identities);
$this->assertThat((string) $rules, $this->equalTo(json_encode($result)));
// Merge a new set, flipping some bits.
$identities = array(-42 => 0, 2 => 1, 3 => 1, 4 => 1);
// Ident 3 should remain false, 4 should be added.
$result = array('edit' => array(-42 => 0, 2 => 1, 3 => 0, 4 => 1));
$rules->mergeAction('edit', $identities);
$this->assertThat((string) $rules, $this->equalTo(json_encode($result)));
}
示例2: save
/**
* @return bool
*/
public function save()
{
$result = parent::save();
if ($result) {
$this->_createFilesContainer();
$this->_createIconsContainer();
$this->_createImagesContainer();
if (file_exists(dirname(__FILE__) . '/../../install/mimetypes.sql')) {
$query = file_get_contents(dirname(__FILE__) . '/../../install/mimetypes.sql');
if ($query) {
$db = JFactory::getDBO();
$db->setQuery($query);
$db->queryBatch(false);
}
}
// Remove com_files from the menu table
$db = JFactory::getDBO();
$db->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_files'");
$id = $db->loadResult();
if ($id) {
$table = JTable::getInstance('menu');
$table->bind(array('id' => $id));
$table->delete();
}
// Add a rule to authorize Public group to download
if ($this->event === 'install') {
$asset = JTable::getInstance('Asset');
$asset->loadByName('com_docman');
$rules = new JAccessRules($asset->rules);
$rules->mergeAction('com_docman.download', new JAccessRule(array(1 => true)));
$asset->rules = (string) $rules;
if ($asset->check()) {
$asset->store();
}
unset($asset);
$asset = JTable::getInstance('Asset');
$asset->loadByName('com_docman');
$rules = new JAccessRules($asset->rules);
$rules->mergeAction('com_docman.upload', new JAccessRule(array(6 => true, 2 => true)));
$asset->rules = (string) $rules;
if ($asset->check()) {
$asset->store();
}
}
if ($this->old_version) {
$this->_migrate();
}
}
return $result;
}
示例3: save
/**
* @return bool
*/
public function save()
{
$result = parent::save();
if ($result) {
$this->_createFilesContainer();
$this->_createIconsContainer();
$this->_createImagesContainer();
if (file_exists(dirname(__FILE__) . '/../../resources/install/mimetypes.sql')) {
$mimetypes = file_get_contents(dirname(__FILE__) . '/../../resources/install/mimetypes.sql');
if ($mimetypes) {
try {
$db = JFactory::getDBO();
$queries = $db->splitSql($mimetypes);
foreach ($queries as $query) {
if (trim($query)) {
$db->setQuery($query)->execute();
}
}
} catch (Exception $e) {
}
}
}
if ($this->event === 'install') {
// Add a rule to authorize Public group to download
$asset = JTable::getInstance('Asset');
$asset->loadByName('com_docman');
$rules = new JAccessRules($asset->rules);
$rules->mergeAction('com_docman.download', new JAccessRule(array(1 => true)));
$asset->rules = (string) $rules;
if ($asset->check()) {
$asset->store();
}
// Disable finder plugin by default
$finder_id = $this->getExtensionId(array('type' => 'plugin', 'element' => 'docman', 'folder' => 'finder'));
if ($finder_id) {
$query = sprintf('UPDATE #__extensions SET enabled = 0 WHERE extension_id = %d', $finder_id);
JFactory::getDBO()->setQuery($query)->query();
}
}
if ($this->old_version) {
JCache::getInstance('output', array('defaultgroup' => 'com_docman.files'))->clean();
$this->_migrate();
}
}
return $result;
}