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


PHP AuthItem::setIsNewRecord方法代码示例

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


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

示例1: actionEdit

 /**
  * 
  * @desc
  */
 public function actionEdit()
 {
     $this->checkAccess('RbacViewer', true);
     $model = new AuthItem();
     if (empty($_POST)) {
         if (isset($_GET['item'])) {
             if (in_array($_GET['item'], $this->protectedItems)) {
                 $this->messageErrors[] = "Warning! Item is protected by Controller";
             }
             $model->attributes = $_GET;
             if ($model->validate()) {
                 $name = urldecode($_GET['item']);
                 if ($item = $model->findByAttributes(array('name' => $name))) {
                     // display edit Item box
                     $this->editItem = $item;
                     $this->actionIndex();
                 } else {
                     $this->messageErrors[] = "The Item you want to edit does not exist";
                 }
             } else {
                 $this->messageErrors[] = "Unsecure Data detected. Please mail the Siteadmin if this Problem returns.";
             }
         } else {
             //ignore missing item and display index
             $this->actionIndex();
         }
     } else {
         $this->checkAccess('RbacEditor', true);
         // filter names
         $_POST['editItem']['name'] = $this->filterString($_POST['editItem']['name'], $this->filterNames);
         $model->attributes = $_POST['editItem'];
         $oldName = $_POST['oldName'];
         if (in_array($oldName, $this->protectedItems) || in_array($_POST['editItem']['name'], $this->protectedItems)) {
             $this->messageErrors[] = "Sorry, Item is protected by Controller";
             $this->actionIndex();
         }
         if ($model->validate()) {
             if (isset($_POST['updateItem'])) {
                 $this->_updateItem($_POST['editItem'], $oldName);
             } elseif (isset($_POST['createItem'])) {
                 if (!AuthItem::model()->findByAttributes(array('name' => $_POST['editItem']['name']))) {
                     $model->setIsNewRecord(true);
                     $model->save();
                     $this->messageSuccess[] = "Item {$_POST['editItem']['name']} successfull created.";
                 } else {
                     $this->messageErrors[] = "Create Error: New Item <i>{$_POST['editItem']['name']}</i> already exists";
                     $this->editItem = $model;
                     $this->actionIndex();
                 }
             } elseif (isset($_POST['deleteItem'])) {
                 AuthItem::model()->deleteAllByAttributes(array('name' => $oldName));
                 AuthItemChild::model()->deleteAllByAttributes(array('parent' => $oldName));
                 AuthItemChild::model()->deleteAllByAttributes(array('child' => $oldName));
                 AuthAssignment::model()->deleteAllByAttributes(array('itemname' => $oldName));
                 $this->messageSuccess[] = "Item {$oldName} successfull deleted.";
             } else {
                 // ignore not existing submit option and render page
             }
             $this->actionIndex();
         } else {
             //use Yii error system
             $model->setIsNewRecord(true);
             $this->editItem = $model;
             $this->actionIndex();
         }
     }
 }
开发者ID:ranvirp,项目名称:rdp,代码行数:71,代码来源:RbacController.php


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