/** * Store a newly created group in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Staff::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } Staff::create($data); return Redirect::route('staffs.index'); }
include_once(INCLUDE_DIR.'class.staff.php'); $do=strtolower($_POST['do']); switch($do){ case 'update': $staff = new Staff($_POST['staff_id']); if($staff && $staff->getId()) { if($staff->update($_POST,$errors)) $msg='Staff profile updated successfully'; elseif(!$errors['err']) $errors['err']='Error updating the user'; }else{ $errors['err']='Internal error'; } break; case 'create': if(($uID=Staff::create($_POST,$errors))) $msg=Format::htmlchars($_POST['firstname'].' '.$_POST['lastname']).' added successfully'; elseif(!$errors['err']) $errors['err']='Unable to add the user. Internal error'; break; case 'mass_process': //ok..at this point..look WMA. if($_POST['uids'] && is_array($_POST['uids'])) { $ids=implode(',',$_POST['uids']); $selected=count($_POST['uids']); if(isset($_POST['enable'])) { $sql='UPDATE '.STAFF_TABLE.' SET isactive=1,updated=NOW() WHERE isactive=0 AND staff_id IN('.$ids.')'; db_query($sql); $msg=db_affected_rows()." of $selected selected users enabled"; }elseif(in_array($thisuser->getId(),$_POST['uids'])) {
if (isset($_REQUEST["weekend"])) { $mysqli->query("UPDATE ost_staff SET weekend_alert = '1' WHERE staff_id = " . $_REQUEST["id"]); } else { $mysqli->query("UPDATE ost_staff SET weekend_alert = '0' WHERE staff_id = " . $_REQUEST["id"]); } // Anthony 2016-01-18 if (!$staff) { $errors['err'] = sprintf(__('%s: Unknown or invalid'), __('agent')); } elseif ($staff->update($_POST, $errors)) { $msg = sprintf(__('Successfully updated %s'), __('this agent')); } elseif (!$errors['err']) { $errors['err'] = sprintf(__('Unable to update %s. Correct error(s) below and try again!'), __('this agent')); } break; case 'create': if ($id = Staff::create($_POST, $errors)) { $msg = sprintf(__('Successfully added %s'), Format::htmlchars($_POST['firstname'])); $_REQUEST['a'] = null; } elseif (!$errors['err']) { $errors['err'] = sprintf(__('Unable to add %s. Correct error(s) below and try again.'), __('this agent')); } break; case 'mass_process': if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { $errors['err'] = sprintf(__('You must select at least %s.'), __('one agent')); } elseif (in_array($thisstaff->getId(), $_POST['ids'])) { $errors['err'] = __('You can not disable/delete yourself - you could be the only admin!'); } else { $count = count($_POST['ids']); switch (strtolower($_POST['a'])) { case 'enable':
function authOrCreate($username) { global $cfg; switch ($this->type) { case 'staff': if (($user = StaffSession::lookup($username)) && $user->getId()) { if (!$user instanceof StaffSession) { // osTicket <= v1.9.7 or so $user = new StaffSession($user->getId()); } return $user; } else { $staff_groups = preg_split('/;|,/', $config->get('multiauth-staff-group')); $chkgroup; foreach ($staff_groups as $staff_group) { if ($ldap->checkGroup($name, $staff_group)) { $chkgroup = true; break; } } $config = $this->getConfig(); if ($config->get('multiauth-staff-register') && $chkgroup) { if (!($info = $this->lookup($username, false))) { return; } $errors = array(); $staff = array(); $staff['username'] = $info['username']; $staff['firstname'] = $info['first']; $staff['lastname'] = $info['last']; $staff['email'] = $info['email']; $staff['isadmin'] = 0; $staff['isactive'] = 1; $staff['group_id'] = 1; $staff['dept_id'] = 1; $staff['welcome_email'] = "on"; $staff['timezone_id'] = 8; $staff['isvisible'] = 1; Staff::create($staff, $errors); if (($user = StaffSession::lookup($username)) && $user->getId()) { if (!$user instanceof StaffSession) { $user = new StaffSession($user->getId()); } return $user; } } } break; case 'client': // Lookup all the information on the user. Try to get the email // addresss as well as the username when looking up the user // locally. if (!($info = $this->search($username)[0])) { return; } $acct = ClientAccount::lookupByUsername($username); if ($acct && $acct->getId()) { $client = new ClientSession(new EndUser($acct->getUser())); } if (!$client) { $info['name'] = $info['first'] . " " . $info['last']; $client = new ClientCreateRequest($this, $username, $info); //if (!$cfg || !$cfg->isClientRegistrationEnabled() && self::$config->get('multiauth-force-register')) { // return $client->attemptAutoRegister(); //} } return $client; } return null; }