public function editAction()
 {
     $this->view->title = "Permission - Edit";
     $this->view->headTitle(" -  " . $this->view->title);
     $id = $this->_getParam('id');
     $model1 = new Application_Model_Permission();
     $model = $model1->find($id);
     $options['name'] = $model->getName();
     $request = $this->getRequest();
     $form = new Admin_Form_Permission();
     $form->populate($options);
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($form->isValid($options)) {
             $model->setOptions($options);
             $model->save($model);
             $this->view->successMsg = "Permission Id : {$model->getId()}' has been updated successfully!";
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
示例#2
0
 private function setModel($row)
 {
     $model = new Application_Model_Permission();
     $model->setId($row->id)->setName($row->name)->setAddedon($row->addedon)->setUpdatedon($row->updatedon)->setUserId($row->user_id);
     return $model;
 }
示例#3
0
 public function setDefaultPermissions($user_id)
 {
     $permissionM = new Application_Model_Permission();
     $permissions = $permissionM->fetchAll();
     if (count($permissions) > 0) {
         /*-- add default user friend group --*/
         /*$friend_group=new Application_Model_FriendGroup();
         		$defaultG=$friend_group->getDefaultFriendGroups();
         		$friend_group->setName($defaultG[0]);
         		$friend_group->setUserId($user_id);
         		$friend_group_id=$friend_group->save();*/
         /*-----------------------------*/
         foreach ($permissions as $_permission) {
             $userPermission = new Application_Model_UserPermission();
             $userPermission->setPermissionId($_permission->getId());
             $userPermission->setFriendGroupId(5);
             //set 1 to 5 on 5-march-2011 by mahipal
             $userPermission->setUserId($user_id);
             $userPermission->save();
         }
         /*--- set all default friend group ----*/
         /*for($i=1;$i<count($defaultG);$i++)
         		{
         			$friend_group->setName($defaultG[$i]);
         			$friend_group->setUserId($user_id);
         			$friend_group->save();
         		}*/
         /*--------------------------------------*/
     }
 }