本文整理匯總了PHP中sfGuardUserGroupPeer::retrieveByPK方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfGuardUserGroupPeer::retrieveByPK方法的具體用法?PHP sfGuardUserGroupPeer::retrieveByPK怎麽用?PHP sfGuardUserGroupPeer::retrieveByPK使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfGuardUserGroupPeer
的用法示例。
在下文中一共展示了sfGuardUserGroupPeer::retrieveByPK方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: executePermissions
public function executePermissions(sfWebRequest $request)
{
$module = 'sfGuardUser';
if (!in_array($module, array_keys(sfPlop::getSafePluginModules()))) {
$this->redirect('@sf_plop_dashboard');
}
if ($request->isMethod(sfRequest::POST)) {
if ($request->isXmlHttpRequest()) {
$this->setTemplate('ajaxPermissions');
$this->setLayout(false);
}
$group_id = $request->getParameter('g');
$user_id = $request->getParameter('u');
$permission_id = $request->getParameter('p');
if ($group_id) {
$group_exists = sfPlopGuard::groupExists($group_id);
if (!$group_exists && $request->isXmlHttpRequest()) {
return sfView::ERROR;
} else {
if (!$group_exists) {
$this->redirect('@sf_plop_dashboard_permissions');
}
}
}
if ($user_id) {
$user_exists = sfPlopGuard::userExists($user_id);
if (!$user_exists && $request->isXmlHttpRequest()) {
return sfView::ERROR;
} else {
if (!$user_exists) {
$this->redirect('@sf_plop_dashboard_permissions');
}
}
}
if (isset($group_exists) && isset($user_exists)) {
$user_group = sfGuardUserGroupPeer::retrieveByPK($user_id, $group_id);
if ($user_group) {
$user_group->delete();
} else {
$user_group = new sfGuardUsergroup();
$user_group->setUserId($user_id);
$user_group->setGroupId($group_id);
$user_group->save();
$this->getResponse()->setStatusCode(201);
}
}
if ($permission_id) {
if ($permission_id == 'super') {
if (!sfPlopGuard::isLastSuperAdminUser($user_id)) {
$user = sfGuardUserPeer::retrieveByPK($user_id);
if ($user->getIsSuperAdmin()) {
$user->setIsSuperAdmin(false);
} else {
$user->setIsSuperAdmin(true);
}
$user->save();
} else {
$this->getResponse()->setStatusCode(202);
return sfView::ERROR;
}
} else {
if (!is_int($permission_id)) {
$permission_exists = sfPlopGuard::permissionExists($permission_id);
if (!$permission_exists) {
$modules = sfPlop::getSafePluginModules();
if ($request->isXmlHttpRequest() && !isset($modules[$permission_id])) {
return sfView::ERROR;
} elseif (!isset($modules[$permission_id])) {
$this->redirect('@sf_plop_dashboard_permissions');
} else {
$module = $modules[$permission_id];
}
$permission = new sfGuardPermission();
$permission->setName($permission_id);
$permission->setDescription($module['name']);
$permission->save();
$permission_id = $permission->getId();
$this->getResponse()->setStatusCode(201);
} else {
$permission_id = sfPlopGuard::getPermission($permission_id)->getId();
}
} else {
$permission_exists = sfPlopGuard::permissionExists($permission_id);
if (!$permission_exists && $request->isXmlHttpRequest()) {
return sfView::ERROR;
} else {
if (!$permission_exists) {
$this->redirect('@sf_plop_dashboard_permissions');
}
}
}
if (isset($user_exists)) {
$user_permission = sfGuardUserPermissionPeer::retrieveByPK($user_id, $permission_id);
if ($user_permission) {
$user_permission->delete();
} else {
$user_permission = new sfGuardUserPermission();
$user_permission->setUserId($user_id);
$user_permission->setPermissionId($permission_id);
$user_permission->save();
//.........這裏部分代碼省略.........