Пример #1
0
 public function deleteAction()
 {
     $id = $this->getParam('id');
     $user = new Model_User($id);
     $user->delete();
     $this->_helper->redirector('index');
 }
Пример #2
0
 public function action_delete()
 {
     $user = new Model_User($this->request->param('id'));
     if ($user->loaded()) {
         $user->delete();
     }
     $this->redirect('admin/user/all');
 }
Пример #3
0
 public function userdeleteAction()
 {
     $user = new Model_User();
     if ($user->findById($this->getParamNumeric(AdminController::USER_PARAM))) {
         $user->delete();
         $this->getLog()->info("Deleted {$user}");
     }
     return $this->_helper->redirector('index');
 }
Пример #4
0
 public function deleteAction()
 {
     //定义删除方法
     $table = new Model_User();
     //类的实例化
     $where = 'id = 2';
     //定义删除的条件
     if ($table->delete($where)) {
         //执行删除操作
         $this->view->delete = "删除成功!";
     } else {
         $this->view->delete = "该数据已经不存在";
     }
 }
Пример #5
0
 public function action_delete($nip)
 {
     $this->template->title = "Delete Dosen";
     $dosen = new Model_Dosen($nip);
     $user = new Model_User($dosen->user_id);
     $user->delete();
     Request::instance()->redirect('dosen/list');
 }
Пример #6
0
 public function action_delete($nim)
 {
     $this->template->title = "Delete Mahasiswa";
     $mahasiswa = new Model_Mahasiswa($nim);
     $user = new Model_User($mahasiswa->user_id);
     $user->delete();
     // redirect
     Request::instance()->redirect('mahasiswa/list');
 }
Пример #7
0
 public function userAction($iId = null)
 {
     $this->mTemplate->sSectionTitle = $this->getLang('section_title_useredit');
     // sprawdzamy czy user jest adminem
     if ($this->sRole !== 'admin') {
         $aData['info'] = $this->getLang('access_denied');
         $this->mTemplate->content = View::factory('account/item_edit', $aData)->render();
         return;
     }
     if (isset($iId) and $iId !== 0 and !isset($_POST['submit'])) {
         // edycja usera
         $bDelete = func_get_arg(0) == 'delete';
         if ($bDelete) {
             $iId = func_get_arg(1);
         }
         $iId = (int) $iId;
         $oUser = new Model_User($iId);
         $aUser = $oUser->getRow();
         if ($iId and !empty($aUser) and $aUser['account_id'] == $this->oCurrentUser->account_id) {
             if ($bDelete) {
                 // usuwanie uzytkownika
                 if (func_num_args() == 4 and $this->oAuth->isValidToken(func_get_arg(2))) {
                     if ($oUser->delete()) {
                         $aMeta = $this->mTemplate->aMeta;
                         $aMeta[] = '<meta http-equiv="refresh" content="1;url=' . $this->mTemplate->anchor('/account/users/') . '" />';
                         $this->mTemplate->aMeta = $aMeta;
                         $aData['info'] = $this->getLang('delele_user_successfull');
                     } else {
                         $aData['info'] = $this->getLang('delele_user_failed');
                     }
                 } else {
                     // potwierdzenie usuniecia
                     $aData = array('sQuestion' => $this->getLang('delele_user_question', $aUser['name']), 'sTextYes' => $this->getLang('Catering.ok'), 'sLinkYes' => '/account/user/delete/' . $iId . '/' . $this->oAuth->getSecurityToken() . '/', 'sTextNo' => $this->getLang('Catering.cancel'), 'sLinkNo' => '/account/user/' . $iId . '/');
                 }
                 $this->mTemplate->sSectionTitle = $this->getLang('section_title_userdelete');
             } else {
                 // edycja danych
                 $aOptions = array();
                 $aLayoutList = array();
                 $oRole = new Model_Role();
                 $aRoles = $oRole->getAll();
                 foreach ($aRoles as $aRole) {
                     $aOptions[] = array('value' => $aRole['role_id'], 'name' => $aRole['name']);
                 }
                 // pobieramy dostepne layouty
                 $oLayout = new Model_Layout();
                 $aLayouts = $oLayout->getAll();
                 foreach ($aLayouts as $aLayout) {
                     $aLayoutList[] = array('value' => $aLayout['layout_id'], 'name' => $aLayout['name']);
                 }
                 $aInputs[] = array('type' => 'text', 'label' => $this->getLang('first_name'), 'name' => 'fname', 'value' => $aUser['fname']);
                 $aInputs[] = array('type' => 'text', 'label' => $this->getLang('sure_name'), 'name' => 'name', 'value' => $aUser['name']);
                 $aInputs[] = array('type' => 'text', 'label' => $this->getLang('email'), 'name' => 'email', 'value' => $aUser['email']);
                 $aInputs[] = array('type' => 'password', 'label' => $this->getLang('password'), 'name' => 'pass', 'value' => '');
                 $aInputs[] = array('type' => 'text', 'label' => $this->getLang('registered'), 'name' => 'since', 'value' => $aUser['since'], 'disabled' => true);
                 $aInputs[] = array('type' => 'text', 'label' => $this->getLang('last_login'), 'name' => 'last_login', 'value' => $aUser['last_login'], 'disabled' => true);
                 $aInputs[] = array('type' => 'select', 'label' => $this->getLang('layout'), 'name' => 'layout', 'value' => $aUser['layout_id'], 'items' => $aLayoutList);
                 $aInputs[] = array('type' => 'select', 'label' => $this->getLang('role'), 'name' => 'role', 'value' => $aUser['role_id'], 'items' => $aOptions);
                 $aInputs[] = array('type' => 'hidden', 'name' => 'user_id', 'value' => $aUser['user_id']);
                 $aData = array('bPrintForm' => true, 'aInputs' => $aInputs, 'sTextDelete' => $this->getLang('delete'), 'sLinkDelete' => '/account/user/delete/' . $aUser['user_id'] . '/');
                 $this->mTemplate->sSectionTitle = $this->getLang('section_title_useredit');
             }
         } else {
             $aData['info'] = $this->getLang('user_not_found');
         }
     } elseif (isset($_POST['submit'])) {
         // zapis usera
         $sFName = $this->post('fname');
         $sName = $this->post('name');
         $sPass = $this->post('pass');
         $sEmail = $this->post('email');
         $iRole = $this->post('role');
         $iLayout = $this->post('layout');
         $user_id = $this->post('user_id');
         $oValidator = new Module_Validator();
         $oValidator->field('first_name', $sFName)->rules('required');
         $oValidator->field('sure_name', $sName)->rules('required');
         $oValidator->field('email', $sEmail)->rules('required|email');
         $oValidator->field('layout', $iLayout)->rules('required|toint');
         $oValidator->field('role', $iRole)->rules('required|toint');
         $oValidator->field('user_id', $user_id)->rules('toint');
         if ($user_id == 0) {
             $oValidator->field($this->getLang('password'), $sPass)->rules('required|md5');
         } elseif (strlen($sPass)) {
             $oValidator->field($this->getLang('password'), $sPass)->rules('md5');
         }
         if ($oValidator->validate()) {
             if ($user_id == 0) {
                 //zapis nowego usera
                 $oUser = new Model_User();
                 $oUser->fname = $sFName;
                 $oUser->name = $sName;
                 $oUser->email = $sEmail;
                 $oUser->password = $sPass;
                 $oUser->layout_id = $iLayout;
                 $oUser->role_id = $iRole;
                 $oUser->account_id = $this->oCurrentUser->account_id;
                 if ($oUser->save()) {
                     $aMeta = $this->mTemplate->aMeta;
                     $aMeta[] = '<meta http-equiv="refresh" content="1;url=' . $this->mTemplate->anchor('/account/users/') . '" />';
                     $this->mTemplate->aMeta = $aMeta;
                     $aData['info'] = $this->getLang('save_user_successfull');
                 } else {
                     $aData['info'] = $this->getLang('save_user_failed');
                 }
             } else {
                 // zapis edytowanego usera
                 $oUser = new Model_User($user_id);
                 $aUser = $oUser->getRow();
                 if (!empty($aUser) and $aUser['account_id'] == $this->oCurrentUser->account_id) {
                     $oUser->fname = $sFName;
                     $oUser->name = $sName;
                     $oUser->email = $sEmail;
                     $oUser->layout_id = $iLayout;
                     $oUser->role_id = $iRole;
                     if (!empty($sPass)) {
                         $oUser->password = $sPass;
                     }
                     if ($oUser->save()) {
                         $aMeta = $this->mTemplate->aMeta;
                         $aMeta[] = '<meta http-equiv="refresh" content="1;url=' . $this->mTemplate->anchor('/account/users/') . '" />';
                         $this->mTemplate->aMeta = $aMeta;
                         $aData['info'] = $this->getLang('save_user_successfull');
                     } else {
                         $aData['info'] = $this->getLang('save_user_failed');
                     }
                 }
             }
         } else {
             $aErrors = $oValidator->getError();
             foreach ($aErrors as $sField => $aError) {
                 $sMsg .= '<br />' . $this->getLang($aError['msg'], $this->getLang($sField));
             }
             $aData['info'] = $sMsg;
         }
         $this->mTemplate->sSectionTitle = $this->getLang('section_title_user_save');
     } else {
         // akcja domyślna czyli dodawanie usera
         $aOptions = array();
         $aLayoutList = array();
         // pobieramy dostepne role
         $oRole = new Model_Role();
         $aRoles = $oRole->getAll();
         foreach ($aRoles as $aRole) {
             $aOptions[] = array('value' => $aRole['role_id'], 'name' => $aRole['name']);
         }
         // pobieramy dostepne layouty
         $oLayout = new Model_Layout();
         $aLayouts = $oLayout->getAll();
         foreach ($aLayouts as $aLayout) {
             $aLayoutList[] = array('value' => $aLayout['layout_id'], 'name' => $aLayout['name']);
         }
         $aInputs[] = array('type' => 'text', 'label' => $this->getLang('first_name'), 'name' => 'fname', 'value' => '');
         $aInputs[] = array('type' => 'text', 'label' => $this->getLang('sure_name'), 'name' => 'name', 'value' => '');
         $aInputs[] = array('type' => 'text', 'label' => $this->getLang('email'), 'name' => 'email', 'value' => '');
         $aInputs[] = array('type' => 'password', 'label' => $this->getLang('password'), 'name' => 'pass', 'value' => '');
         $aInputs[] = array('type' => 'select', 'label' => $this->getLang('layout'), 'name' => 'layout', 'value' => 2, 'items' => $aLayoutList);
         $aInputs[] = array('type' => 'select', 'label' => $this->getLang('role'), 'name' => 'role', 'value' => 3, 'items' => $aOptions);
         $aData = array('bPrintForm' => true, 'aInputs' => $aInputs);
         $this->mTemplate->sSectionTitle = $this->getLang('section_title_user_add');
     }
     $aData['submit'] = $this->getLang('Catering.save');
     $this->mTemplate->content = View::factory('/account/item_edit', $aData)->render();
 }
Пример #8
0
 /**
  * Delete action
  *
  * Delete a user
  *
  * @return void
  */
 public function deleteAction()
 {
     $userName = $this->_request->getParam('username');
     $u = new Model_User();
     $u->delete("name = '{$userName}'");
     $url = 'admin/site';
     $this->_redirect($url);
 }