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