当前位置: 首页>>代码示例>>PHP>>正文


PHP Acl::setUserGroup方法代码示例

本文整理汇总了PHP中Acl::setUserGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP Acl::setUserGroup方法的具体用法?PHP Acl::setUserGroup怎么用?PHP Acl::setUserGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Acl的用法示例。


在下文中一共展示了Acl::setUserGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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();
         }
     }
 }
开发者ID:taryono,项目名称:school,代码行数:79,代码来源:UserGroup.php

示例2: addAcl

 public function addAcl(Acl $l)
 {
     $this->collAcls[] = $l;
     $l->setUserGroup($this);
 }
开发者ID:taryono,项目名称:school,代码行数:5,代码来源:BaseUserGroup.php


注:本文中的Acl::setUserGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。