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


PHP Roles::fetchImmediateChildren方法代码示例

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


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

示例1: addRoles

 function addRoles($parent_role = null)
 {
     $roles_table = new Roles();
     //dd($roles_table->fetchImmediateChildren(2)->toArray());
     // we start this recursive funtion by looking for roles with no parent.
     if (is_null($parent_role)) {
         $roles = $roles_table->fetchParentless();
     } else {
         $roles = $roles_table->fetchImmediateChildren($parent_role);
         //dd($roles->toArray());
     }
     foreach ($roles as $role) {
         // Add the role and specifiy that as the parent. On the first pass, this is null.
         if (!$this->hasRole($role->id)) {
             Bolts_Log::info("Adding role " . $role->shortname);
             $this->addRole(new Zend_Acl_Role($role->id), $parent_role);
         }
         if (count($roles_table->fetchImmediateChildren($role->id)) > 0) {
             $this->addRoles($role->id);
         }
     }
 }
开发者ID:jaybill,项目名称:Bolts,代码行数:22,代码来源:Acl.php

示例2: deleteAction

 function deleteAction()
 {
     $request = new Bolts_Request($this->getRequest());
     $roles_table = new Roles();
     if ($request->has('id')) {
         $id = $request->id;
         $role = $roles_table->fetchRow("id = " . $id);
         if (is_null($role)) {
             $this->_redirect('/bolts/role');
         }
     } else {
         $this->_redirect('/bolts/role');
     }
     if ($this->getRequest()->isPost() and $request->has("delete")) {
         $errors = array();
         // can't be last admin
         if ((bool) $role->isadmin and $roles_table->getCountByWhereClause("isadmin = 1") == 1) {
             $errors[] = $this->_T("This is the only admin role. It cannot be deleted.");
         }
         // can't be guest
         if ((bool) $role->isguest) {
             $errors[] = $this->_T("This is the guest role. It cannot be deleted.");
         }
         // can't be default
         if ((bool) $role->isdefault) {
             $errors[] = $this->_T("This is the default role. It cannot be deleted.");
         }
         // can't have any users
         $userwhereclause = "role_id = " . $role->id;
         $users_table = new UsersRoles();
         if ($users_table->getCountByWhereClause($userwhereclause) > 0) {
             $errors[] = $this->_T("This role cannot be deleted because there are users assigned to it.");
         }
         // can't have children
         $inherited_by = $roles_table->fetchImmediateChildren($role->id);
         if (count($inherited_by) > 0) {
             $error = $this->_T("This role is inherited by role(s) ");
             $firstpass = true;
             foreach ($inherited_by as $role_i) {
                 if ($firstpass) {
                     $firstpass = false;
                 } else {
                     $error .= ", ";
                 }
                 $error .= $role_i->shortname;
             }
             $error .= $this->_T(". It cannot be deleted.");
             $errors[] = $error;
         }
         if ($request->delete == "Yes") {
             if (count($errors) > 0) {
                 $this->view->errors = $errors;
             } else {
                 $roles_table->delete("id = " . $id);
                 $this->view->success = $this->_T("Role deleted.");
             }
         } else {
             $this->_redirect("/bolts/role");
         }
     }
     $this->view->role = $role->toArray();
 }
开发者ID:jaybill,项目名称:Bolts,代码行数:62,代码来源:RoleController.php


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