本文整理汇总了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;
}
}
示例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");
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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();
}