當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Permissions::save方法代碼示例

本文整理匯總了PHP中Permissions::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Permissions::save方法的具體用法?PHP Permissions::save怎麽用?PHP Permissions::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Permissions的用法示例。


在下文中一共展示了Permissions::save方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create

 function create($aData)
 {
     try {
         $sCode = $aData['PER_CODE'];
         $oCriteria = new Criteria('rbac');
         $oCriteria->add(PermissionsPeer::PER_CODE, $sCode);
         $oDataset = PermissionsPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $aRow = $oDataset->getRow();
         if (is_array($aRow)) {
             return 1;
         }
         $aData['PER_UID'] = G::generateUniqueID();
         $aData['PER_CODE'] = $aData['PER_CODE'];
         $aData['PER_CREATE_DATE'] = date('Y-m-d H:i:s');
         $aData['PER_UPDATE_DATE'] = $aData['PER_CREATE_DATE'];
         $aData['PER_STATUS'] = 1;
         $oPermission = new Permissions();
         $oPermission->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         $iResult = $oPermission->save();
         return $aData['PER_UID'];
     } catch (Exception $oError) {
         throw $oError;
     }
 }
開發者ID:emildev35,項目名稱:processmaker,代碼行數:26,代碼來源:Permissions.php

示例2: store

 function store()
 {
     if (Input::has("key") && Input::has("text")) {
         $permission = new Permissions();
         $permission->key = Input::get("key");
         $permission->text = Input::get("text");
         $permission->save();
         Session::flash("success_msg", trans('msgs.permission_created_success'));
         return Redirect::to("/permissions/create")->withInput();
     } else {
         Session::flash("error_msg", trans('msgs.all_fields_required'));
         return Redirect::to("/permissions/all");
     }
 }
開發者ID:noikiy,項目名稱:Xenon-Support-Center,代碼行數:14,代碼來源:PermissionsController.php

示例3: verifyPermissions

 /**
  * this function permissions
  *
  *
  * @access public
  *
  */
 public function verifyPermissions()
 {
     $message = array();
     $listPermissions = $this->loadPermissionAdmin();
     $criteria = new Criteria('rbac');
     $dataset = PermissionsPeer::doSelectRS($criteria);
     $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $dataset->next();
     $aRow = $dataset->getRow();
     while (is_array($aRow)) {
         foreach ($listPermissions as $key => $item) {
             if ($aRow['PER_UID'] == $item['PER_UID']) {
                 unset($listPermissions[$key]);
                 break;
             }
         }
         $dataset->next();
         $aRow = $dataset->getRow();
     }
     foreach ($listPermissions as $key => $item) {
         $data['PER_UID'] = $item['PER_UID'];
         $data['PER_CODE'] = $item['PER_CODE'];
         $data['PER_CREATE_DATE'] = date('Y-m-d H:i:s');
         $data['PER_UPDATE_DATE'] = $data['PER_CREATE_DATE'];
         $data['PER_STATUS'] = 1;
         $permission = new Permissions();
         $permission->fromArray($data, BasePeer::TYPE_FIELDNAME);
         $permission->save();
         $message[] = 'Add permission missing ' . $item['PER_CODE'];
     }
     return $message;
 }
開發者ID:bqevin,項目名稱:processmaker,代碼行數:39,代碼來源:class.rbac.php

示例4: Acl_db_gen_permissions

 public function Acl_db_gen_permissions($app)
 {
     $handlers = $app->getHandlers();
     $new_permission_log = array();
     $permission_log = array();
     $current_aro = "";
     $id_aro = 0;
     foreach ($handlers as $handler) {
         $aro = str_replace("Controller", "", get_class($handler[0]));
         if ($current_aro != $aro) {
             $current_aro = $aro;
             $sc = "name ='" . $current_aro . "'";
             //si existe el aro
             if (Aros::count($sc)) {
                 $found_aro = Aros::findFirst($sc);
                 $id_aro = $found_aro->getId();
             } else {
                 $new_aro = new Aros();
                 $new_aro->setName($current_aro);
                 $new_aro->save();
                 $new_aro = Aros::findFirst(array("order" => "id", "limit" => "1"));
                 $id_aro = $new_aro->getId();
             }
         }
         $aco = $handler[1];
         $id_aco = 0;
         $sc_acos = array("id_aro='" . $id_aro . "' and name = '" . $aco . "'");
         if (!Acos::count($sc_acos)) {
             $new_aco = new Acos();
             $new_aco->setName($aco);
             $new_aco->setIdAro($id_aro);
             $new_aco->save();
         }
         $found_aco = Acos::findFirst($sc_acos);
         $id_aco = $found_aco->getId();
         $sc_permission = "id_aco ='" . $id_aco . "'";
         //si no existe el permiso
         if (!Permissions::count($sc_permission)) {
             $new_permission = new Permissions();
             $new_permission->setPermissionName($aro . " - " . $aco);
             $new_permission->setIdAco($id_aco);
             $new_permission->save();
             $new_permission_log[] = $aro . " - " . $aco;
         } else {
             $found_permission = Permissions::findFirst($sc_permission);
             $permission_log[] = $found_permission->getPermissionName();
         }
     }
     $log = array();
     $log["created_permissions"] = $new_permission_log;
     $log["already_exist_permissions"] = $permission_log;
     return $log;
 }
開發者ID:julianmc90,項目名稱:phalcon-db-acl-plugin,代碼行數:53,代碼來源:Acl.php

示例5: updatePermissions

 /** #############################################################################
  * 更新數據庫中的Permissions
  * @param dir $ctrlDir
  * @return bool
  */
 function updatePermissions($updateCtrlDir = '')
 {
     if (is_dir($updateCtrlDir) && stripos($updateCtrlDir, '/app/controller/')) {
         $newDbActions = $newPermissions = $delPermissions = array();
         $this->controller_dir = $updateCtrlDir;
         // 得到指定目錄中的全部Actions
         $allActionsarr = $this->find_Permissions();
         $allActionsarr = $this->makeAllActionsEasy($allActionsarr);
         foreach ($allActionsarr as $key => $value) {
             $allActions[] = $value['nca'];
         }
         //return $allPermissions;
         // 得到數據庫中的全部Actions
         $dbActions = Permissions::find()->all()->asArray()->query();
         // 整理成簡單數組的格式
         foreach ($dbActions as $oneActions) {
             $newDbActions[$oneActions['id']] = $oneActions['namespace'] . "_" . $oneActions['controller'] . "_" . $oneActions['action'];
         }
         // 不在數據庫中的Actions將輸入數據庫,先用array_diff取得差值,鍵名保持不變。
         $newPermissions = array_diff($allActions, $newDbActions);
         if (count($newPermissions)) {
             // 構造$newPermissions的鍵名數組,用來構成輸入數據庫的數組
             $creatStr = array();
             foreach ($newPermissions as $key => $newPermission) {
                 //$permissionName = explode('_', $newPermission);
                 $insert_data = new Permissions(array("namespace" => $allActionsarr[$key]['namespace'], "controller" => $allActionsarr[$key]['controller'], "action" => $allActionsarr[$key]['action'], "aliasname" => $allActionsarr[$key]['aliasname']));
                 $insert_data->save();
             }
         }
         // 在數據庫中卻在文件中沒有的Actions將從數據庫刪除
         $delPermissions = array_diff($newDbActions, $allActions);
         if (count($delPermissions)) {
             // 構造要刪除的Actions的id列表
             $delConditions = array();
             foreach ($delPermissions as $key => $delPermission) {
                 Permissions::meta()->destroyWhere('id = ?', $key);
             }
         }
         return true;
     } else {
         return false;
     }
 }
開發者ID:Debenson,項目名稱:openwan,代碼行數:48,代碼來源:permissions.php

示例6: insertPermissionsGroup

 public function insertPermissionsGroup($array)
 {
     $modelPrac = new Pracivnuku();
     $modelPerm = new Permissions();
     $groupModel = new Group();
     foreach ($array as $k => $v) {
         $modelPerm->{$k} = $v;
     }
     $modelPerm->save();
     return Yii::app()->db->getLastInsertID();
 }
開發者ID:vitikstar,項目名稱:10.0.0.10,代碼行數:11,代碼來源:Permissions.php


注:本文中的Permissions::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。