本文整理汇总了PHP中Acl::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Acl::save方法的具体用法?PHP Acl::save怎么用?PHP Acl::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Acl
的用法示例。
在下文中一共展示了Acl::save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveAcls
protected function saveAcls($acls, $role)
{
foreach ($acls as $acl) {
$acl = explode("/", $acl);
$dbAcl = new Acl();
$dbAcl->setIdRole($role);
$dbAcl->setController($acl[0]);
$dbAcl->setAction($acl[1]);
$dbAcl->save();
}
}
示例2: set
public static function set($group, $key, $allowed)
{
if ($acl = self::get($group, $key))
{
$acl->allowed = $allowed;
}
else
{
$acl = new Acl($group, $key, $allowed);
}
$acl->save();
}
示例3: getReadOnlyAcl
/**
* Get the ACL that can be used to make things read only for everyone.
*
* @return \Acl
*/
public function getReadOnlyAcl()
{
$acl_id = \GO::config()->get_setting('readonly_acl_id');
$acl = Acl::model()->findByPk($acl_id);
if (!$acl) {
$acl = new Acl();
$acl->description = 'readonly';
$acl->save();
$acl->addGroup(\GO::config()->group_everyone, Acl::READ_PERMISSION);
\GO::config()->save_setting('readonly_acl_id', $acl->id);
}
return $acl;
}
示例4: updateAcl
public function updateAcl($new_job, $new_acl)
{
foreach ($new_acl as $nk => $nv) {
if (isset($nv['add']) && $nv['add'] == 'on') {
$new_acl[$nk]['add'] = 1;
} else {
$new_acl[$nk]['add'] = null;
}
if (isset($nv['edit']) && $nv['edit'] == 'on') {
$new_acl[$nk]['edit'] = 1;
} else {
$new_acl[$nk]['edit'] = null;
}
if (isset($nv['remove']) && $nv['remove'] == 'on') {
$new_acl[$nk]['remove'] = 1;
} else {
$new_acl[$nk]['remove'] = null;
}
}
$acls = $this->getAcls(new Criteria());
$old = array();
foreach ($acls as $acl) {
$old['job_' . $acl->getJobId()] = array('add' => $acl->getAddPriv(), 'edit' => $acl->getEditPriv(), 'remove' => $acl->getRemovePriv());
}
$removed = array_diff_key($old, $new_job);
$inserted = array_diff_key($new_job, $old);
$nc = array_intersect_key($new_acl, $new_job);
$vc = array();
foreach ($old as $k => $v) {
if (!isset($new_acl[$k]) && ($old[$k]['add'] == '1' || $old[$k]['edit'] == '1' || $old[$k]['remove'] == '1')) {
$vc[$k] = array('add' => null, 'edit' => null, 'remove' => null);
}
if (isset($new_acl[$k])) {
if ($new_acl[$k]['add'] != $old[$k]['add'] || $new_acl[$k]['edit'] != $old[$k]['edit'] || $new_acl[$k]['remove'] != $old[$k]['remove']) {
$vc[$k] = array('add' => $new_acl[$k]['add'], 'edit' => $new_acl[$k]['edit'], 'remove' => $new_acl[$k]['remove']);
}
}
}
if ($inserted) {
foreach ($inserted as $k => $v) {
$job_id = preg_split('/_/', $k);
$job_id = $job_id[1];
$acl = new Acl();
$acl->setUserGroup($this);
$acl->setJobId($job_id);
if (isset($new_acl[$k])) {
if (isset($new_acl[$k]['add'])) {
$acl->setAddPriv($new_acl[$k]['add']);
}
if (isset($new_acl[$k]['edit'])) {
$acl->setEditPriv($new_acl[$k]['edit']);
}
if (isset($new_acl[$k]['remove'])) {
$acl->setRemovePriv($new_acl[$k]['remove']);
}
}
$acl->save();
}
}
if ($removed) {
foreach ($removed as $k => $v) {
$job_id = preg_split('/_/', $k);
$job_id = $job_id[1];
$acl = AclPeer::retrieveByPK($this->getId(), $job_id);
$acl->delete();
}
}
if ($vc) {
foreach ($vc as $k => $v) {
$job_id = preg_split('/_/', $k);
$job_id = $job_id[1];
$acl = AclPeer::retrieveByPK($this->getId(), $job_id);
$acl->setAddPriv($v['add']);
$acl->setEditPriv($v['edit']);
$acl->setRemovePriv($v['remove']);
$acl->save();
}
}
}
示例5: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Acl();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Acl'])) {
$model->attributes = $_POST['Acl'];
if ($model->save()) {
Yii::app()->user->setFlash('success', 'Saved successfully');
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例6: on_after_save
protected function on_after_save($was_new)
{
if ($this->_attr !== null) {
$res_attr = array();
foreach ($this->_attr as $attrs) {
foreach ($attrs as $attr) {
if ($attr['v'] === null) {
if ($attr['i'] != 0) {
SRecord::remove_by_id('Attribute', $attr['i']);
}
} else {
$attr['v']->node_id = $this->id;
if ($attr['v']->is_dirty()) {
$attr['v']->save();
}
if (!array_key_exists('n' . $attr['v']->name, $res_attr)) {
$res_attr['n' . $attr['v']->name] = array();
}
$res_attr['n' . $attr['v']->name]['n' . $attr['v']->lang] = array('i' => $attr['v']->id, 'v' => $attr['v']);
}
}
}
$this->_attr = $res_attr;
$res_attr = null;
}
if ($this->_acl !== null) {
$existing_acl = array();
foreach ($this->acl as $acl) {
$existing_acl[urlencode($acl->action) . ':' . urlencode($acl->ident)] = true;
if (!array_key_exists($acl->action, $this->_acl) || !array_key_exists($this->_acl[$acl->action], $acl->ident) || !$this->_acl[$acl->action][$acl->ident]) {
$acl->remove();
}
}
foreach ($this->_acl as $action) {
foreach ($this->_acl[$action] as $ident) {
if ($this->_acl[$action][$ident] && !array_key_exists(urlencode($action) . ':' . urlencode($ident))) {
$acl = new Acl();
$acl->node_id = $this->id;
$acl->action = $action;
$acl->ident = $ident;
$acl->save();
}
}
}
}
$path = CMS . "modules/{$this->type}/model.php";
if (is_readable($path)) {
require_once $path;
$class_name = Cms::capitalize_words($this->type);
if (is_callable(array($class_name, '_saved'))) {
call_user_func(array($class_name, '_saved'), $this, $was_new);
}
}
}