public function executeAcceptauth() { $user = UserPeer::retrieveByPK($this->getUser()->getAttribute('userid')); $userrole = new Userrole(); $userrole->setRoleId(sfConfig::get('app_role_auth')); $userrole->setUserId($user->getId()); $userrole->save(); $user->setIsinvited('0'); $user->save(); $this->setFlash('notice', 'Invitation accepted. You are an Authorizer now.'); $this->redirect('/settings/invites'); }
public function getIndex() { $data['pageTitle'] = "Quizzler | Users"; //$data['urlAddBack'] = "backends/users/add"; $data['urlAddBack'] = "#"; $data['btnAddBack'] = '<i class="icon-plus"></i><span>Add<span>'; $data['labelPage'] = "The Quizzler"; if (isset($_GET['keyword'])) { $userRoleId = $_GET['keyword']; if ($_GET['keyword'] != '') { $data['users'] = User::where('user_role_id', $userRoleId)->orderBy('created_at', 'asc')->paginate(10); } else { $data['users'] = User::orderBy('created_at', 'asc')->paginate(10); } } else { $userRoleId = 1; $data['users'] = User::where('user_role_id', $userRoleId)->orderBy('created_at', 'asc')->paginate(10); } $data['userType'] = $userRoleId; $userRole = Userrole::orderBy('name', 'asc')->get(); $userRoleArr = ['' => '-- All users --']; foreach ($userRole as $role) { $userRoleArr[$role->id] = $role->name; } $data['userRole'] = $userRoleArr; $result = Results::all(); $resultArr = []; foreach ($result as $rs) { $resultArr[$rs->user_id] = $rs->user_id; } $data['resultArr'] = $resultArr; $data['formOrigin'] = "users"; $data['activeU'] = 'active'; return View::make('backends.users.users', $data); }
public function executeAssignrole() { $roleid = $this->getRequestParameter('role'); $userid = $this->getRequestParameter('assignee'); $user = UserPeer::retrieveByPK($userid); $c = new Criteria(); $c->add(UserrolePeer::USER_ID, $userid); $c->add(UserrolePeer::ROLE_ID, $roleid); $userrole = UserrolePeer::doSelectOne($c); if ($userrole) { $this->setFlash('notice', 'This role is already assigned for <b>' . $user->getFullname() . '</b>'); $this->redirect('/search/result'); } $userrole = new Userrole(); $userrole->setUserId($userid); $userrole->setRoleId($roleid); $userrole->save(); $this->setFlash('notice', 'Role assigned successfully for <b>' . $user->getFullname() . '</b>'); $this->redirect('/search/result'); }
/** * API Method inserts a new Userrole record and render response as JSON */ public function Create() { try { $json = json_decode(RequestUtil::GetBody()); if (!$json) { throw new Exception('The request body does not contain valid JSON'); } $userrole = new Userrole($this->Phreezer); // TODO: any fields that should not be inserted by the user should be commented out // this is an auto-increment. uncomment if updating is allowed // $userrole->Iduserrole = $this->SafeGetVal($json, 'iduserrole'); $userrole->User = $this->SafeGetVal($json, 'user'); $userrole->Role = $this->SafeGetVal($json, 'role'); $userrole->Validate(); $errors = $userrole->GetValidationErrors(); if (count($errors) > 0) { $this->RenderErrorJSON('Please check the form for errors', $errors); } else { $userrole->Save(); $this->RenderJSON($userrole, $this->JSONPCallback(), true, $this->SimpleObjectParams()); } } catch (Exception $ex) { $this->RenderExceptionJSON($ex); } }
public function addUserrole(Userrole $l) { $this->collUserroles[] = $l; $l->setRole($this); }
public function apply() { //turned off die; if (!check_captcha()) { $this->templatemanager->notify_next(__("You have entered wrong security code."), "error", __("Error!")); redirect("administration/auth/register"); die; } $this->load->helper('email'); //get all $name = trim($this->input->post("name", true)); $email = trim($this->input->post("email", true)); $pass = trim($this->input->post("password", true)); $pass2 = trim($this->input->post("password2", true)); //check if all present if (empty($name) || empty($email) || empty($pass) || empty($pass)) { $this->templatemanager->notify_next(__("Please fill all fields so you can continue."), "error", __("Error")); redirect("administration/auth/register"); } if (strlen($name) < 5) { $this->templatemanager->notify_next(__("Name must be longer than 4 characters!"), "error", __("Error")); redirect("administration/auth/register"); } //check e-mail validity if (!valid_email($email)) { $this->templatemanager->notify_next(__("Entered e-mail address was not valid."), "error", __("Error")); redirect("administration/auth/register"); } //check if passwords are the same if ($pass != $pass2) { $this->templatemanager->notify_next(__("Passwords differ."), "error", __("Error")); redirect("administration/auth/register"); } //check user by email $user = User::factory()->get_by_email($email); if ($user->exists()) { $this->templatemanager->notify_next(__("User with that e-mail address already exists."), "error", __("Error")); redirect("administration/auth/register"); } //create user $newu = new User(); $newu->name = $name; $newu->email = $email; $newu->password = $pass; $newu->key = random_string('unique'); $role = Userrole::get_lowest(); $newu->save($role); //set variables for template $vars = array('name' => $name, 'email' => $email, 'password' => $pass, 'website_title' => Setting::value('website_title', CS_PRODUCT_NAME), 'activation_link' => site_url('administration/auth/activate/' . $newu->id . '/' . $newu->key), 'site_url' => site_url()); //get email template $template = file_get_contents(APPPATH . "templates/register.html"); $template = __($template, null, 'email'); $template .= "<br />\n<br />\n<br />\n" . __(file_get_contents(APPPATH . "templates/signature.html"), null, 'email'); $template = parse_template($template, $vars); //send email $this->email->to("{$name} <{$email}>"); $this->email->subject(__("%s registration", Setting::value('website_title', CS_PRODUCT_NAME), 'email')); $this->email->message($template); $this->email->set_alt_message(strip_tags($template)); $from = Setting::value("default_email", false); if (empty($from)) { $from = "noreply@" . get_domain_name(true); } $this->email->from($from); $sent = $this->email->send(); if ($sent) { $this->templatemanager->notify_next(__("Account created. Please check your e-mail."), "notice", __("Notice")); } else { $this->templatemanager->notify_next(__("Activation e-mail could not be sent!"), "error", __("Error")); } redirect("administration/auth/login"); }
public function executeManagenewuser() { $ids = $this->getRequestParameter('ids'); $action = $this->getRequestParameter('action1'); $value = 5; if ($action == 'approve') { $value = 0; } elseif ($action == 'reject') { $value = 1; } $idlist = split(',', $ids); $count = 0; foreach ($idlist as $id) { $user = UserPeer::retrieveByPK($id); $previslocked = 5; if ($user) { $previslocked = $user->getIslocked(); $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $user->getId()); $personal = PersonalPeer::doSelectOne($c); $name = $personal->getFirstname() . " " . $personal->getMiddlename() . " " . $personal->getLastname(); $newmail = $personal->getEmail(); $newpassword = $this->generatePassword(); $user->setIslocked($value); $user->setPassword($newpassword); $count++; $sendermail = sfConfig::get('app_from_mail'); $sendername = sfConfig::get('app_from_name'); $to = $newmail; $subject = "Registration request for ITBHU Global Org"; if ($action == 'approve') { $userrole = new Userrole(); $userrole->setRoleId(sfConfig::get('app_role_user')); $userrole->setUserId($id); $userrole->save(); $academic = new Academic(); $academic->setDegree($user->getDegree()->getName()); $academic->setDegreeflag($user->getDegreeflag()); $academic->setYear($user->getGraduationyear()); $academic->setYearflag($user->getGraduationyearflag()); $academic->setDepartment($user->getBranchname()); $academic->setDepartmentflag($user->getBranchflag()); $academic->setUserId($id); $academic->save(); $c->clear(); $c->add(ClaiminfoPeer::USER_ID, $id); $claiminfo = ClaiminfoPeer::doSelectOne($c); $user->setUsername($claiminfo->getDusername()); $user->save(); $body = ' Dear ' . $name . ', Congrats!! You are now connected to ITBHU GLOBAL. Your Login Details are: Username: '******' Password: '******' Admin, ITBHU Global '; //check if there is any authorizer for the batch.. $ca = new Criteria(); $ca->add(UserPeer::BRANCH_ID, $user->getBranchId()); $ca->add(UserPeer::GRADUATIONYEAR, $user->getGraduationyear()); $ca->addJoin(UserPeer::ID, UserrolePeer::USER_ID); $ca->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_auth')); $authuser = UserPeer::doSelectOne($ca); if (!$authuser) { $body1 = ' Dear ' . $name . ', Currently there are no authorizers for your batch. You are invited for the role of Authorizer for your batch. To accept/reject the invitation, login to http://itbhuglobal.org and go to settings->invitations. On accepting the role, you\'ll recieve approval requests from y- our batchmates. Admin, ITBHU Global '; } } elseif ($action == 'reject') { if ($previslocked == 2) { $user->setIslocked('1'); $user->save(); } else { $user->delete(); $personal->delete(); } $body = ' Dear ' . $name . ', Your connect request to ITBHU GLOBAL is not approved as your details couldn\'t be verified. Admin, ITBHU Global '; } $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body); if ($body1) { $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body1); $body1 = ''; $user->setIsinvited('4'); $user->save(); } } } if ($action == 'approve') { if ($count == 0) { $this->setFlash('newuseraction', 'No user(s) selected to approve'); } else { $this->setFlash('newuseraction', 'You have successfuly approved ' . $count . ' users'); } } elseif ($action == 'reject') { if ($count == 0) { $this->setFlash('newuseraction', 'No user(s) selected to reject'); } else { $this->setFlash('newuseraction', 'You have successfuly rejected ' . $count . ' users'); } } if ($this->getRequestParameter('from') == 'new') { return $this->redirect('auth/newregister'); } else { return $this->redirect('auth/pendinglist'); } }