本文整理汇总了PHP中Permission::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::update方法的具体用法?PHP Permission::update怎么用?PHP Permission::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Permission
<?php
include $_SERVER['DOCUMENT_ROOT'] . '/ControlBalneario/Models/Permission.php';
if ($_GET['action'] == "getAll") {
$p = new Permission();
$all = $p->getAll_json();
print_r($all);
} else {
if ($_GET['action'] == "update") {
$p = new Permission();
$p->create(json_decode($_GET['data'], true));
$p->update();
print "success";
} else {
if ($_GET['action'] == "save") {
}
}
}
示例2: update
public function update()
{
$db = DB::Instance();
$db->StartTrans();
$new_position = $this->_data['position'];
// load sibling permissions
$permissions = new PermissionCollection(new Permission());
$sh = new SearchHandler($permissions, FALSE);
// build the query based on whether a parent_id is available
if (isset($this->_data['parent_id']) && !empty($this->_data['parent_id'])) {
$sh->addConstraint(new Constraint('parent_id', '=', $this->_data['parent_id']));
} else {
$this->_data['parent_id'] = 'null';
$sh->addConstraint(new Constraint('parent_id', 'IS', 'NULL'));
}
// finally, always ignore the current permission
$sh->addConstraint(new Constraint('id', '!=', $this->_data['permission_id']));
$permissions->load($sh);
//***********************************
// CHECK + UPDATE SIBLING PERMISSIONS
$count = 0;
$position_errors = FALSE;
foreach ($permissions as $model) {
// normal increment
$count++;
if ($new_position == $count) {
// we've come across our new item
// increment again, so we make a gap for the new permission
$count++;
}
// there's no point in updating the record if it's already in the correct position
if ($model->position != $count) {
if (!$model->update($model->id, array('position'), array($count))) {
$position_errors = TRUE;
continue;
}
}
}
// no point in proceeding is we've got errors
if ($position_errors === TRUE) {
$db->FailTrans();
$db->CompleteTrans();
echo json_encode(array('success' => FALSE, 'errors' => '<li>Error updating sibling positions</li>'));
exit;
}
$permission = new Permission();
// update the current permission position
if (!$permission->update($this->_data['permission_id'], array('position', 'parent_id'), array($new_position, $this->_data['parent_id']))) {
$db->FailTrans();
$db->CompleteTrans();
echo json_encode(array('success' => FALSE, 'errors' => '<li>Error updating desired position</li>'));
exit;
}
// must have been successful
$db->CompleteTrans();
echo json_encode(array('success' => TRUE));
exit;
}
示例3: Permission
<?php
session_start();
include_once "../php/Permission.php";
if (isset($_POST['save'])) {
$permission = new Permission();
$permission->lockSerial($_POST['lock']);
$permission->recipientIdentification($_POST['recipient']);
$permission->startDateHour($_POST['startDateHour']);
$permission->endDateHour($_POST['endDateHour']);
echo "tt";
$permission->insert();
} elseif (isset($_POST['update'])) {
$permission = new Permission();
$permission->lockSerial($_POST['lock']);
$permission->recipientIdentification($_POST['recipient']);
$permission->startDateHour($_POST['startDateHour']);
$permission->endDateHour($_POST['endDateHour']);
$permission->update();
} elseif (isset($_POST['delete'])) {
Permission::delete($_POST['lock'], $_POST['recipient']);
}
header("location: showPermissions.php");