Exemplo n.º 1
0
 public function getPosts($status = null, $limitQuery = null)
 {
     $P = new post();
     $posts = array();
     if (is_null($status) === true) {
         $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, null);
     } else {
         if (is_array($status) === false) {
             $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE status='{$status}'");
         } else {
             $status_sql = "";
             foreach ($status as $st) {
                 $status_sql .= "status ='{$st}' OR ";
             }
             $status_sql = substr($status_sql, 0, -3);
             $posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE ({$status_sql})");
         }
     }
     $C = new comment();
     foreach ($posts as $k => $p) {
         $posts[$k]['title'] = htmlspecialchars($posts[$k]['title']);
         $posts[$k]['tags'] = $this->getTags($posts[$k]['ID']);
         $posts[$k]['comments_count'] = $C->countCommentsByPost($posts[$k]['ID'], "publish");
         $U = new user();
         if ($posts[$k]['id_user'] < 2) {
             $posts[$k]['autor'] = $U->find(1);
         } else {
             $posts[$k]['autor'] = $U->find($posts[$k]['id_user']);
         }
     }
     return $posts;
 }
Exemplo n.º 2
0
 public function index($id = NULL, $page = 1)
 {
     if (is_null($id) or is_numeric($id)) {
         $this->redirect($this->conf['blog_siteurl']);
     }
     $tag = $id;
     $post = new post();
     $link = new link();
     $comment = new comment();
     $this->html->useTheme($this->conf['blog_current_theme']);
     $info = array();
     $info["isAdmin"] = false;
     if ($this->cookie->check("logged") and $this->cookie->id_user == 1) {
         $info["isAdmin"] = true;
     }
     $this->themes->info = $info;
     $includes['charset'] = $this->html->charsetTag("UTF-8");
     $includes['rssFeed'] = $this->html->includeRSS();
     if ($page > 1) {
         $includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "/{$page}\" />";
     } else {
         $includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "\" />";
     }
     $this->registry->includes = $includes;
     $this->plugin->call('index_includes');
     $includes = null;
     foreach ($this->registry->includes as $include) {
         $includes .= $include;
     }
     $this->themes->includes = $includes;
     $this->themes->links = $link->findAll();
     $this->themes->single = false;
     $total_rows = $post->countPosts(array('status' => 'publish', 'tag' => $tag));
     $page = (int) is_null($page) ? 1 : $page;
     $limit = $this->conf['blog_posts_per_page'];
     $offset = ($page - 1) * $limit;
     $limitQuery = $offset . "," . $limit;
     $targetpage = $this->path . "tag/{$tag}/";
     $this->themes->pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage);
     $posts = $post->getPostsByTag($tag, $limitQuery);
     foreach ($posts as $k => $p) {
         $posts[$k]['title'] = htmlspecialchars($p['title']);
         $posts[$k]['tags'] = $post->getTags($p['ID']);
         $posts[$k]['comments_count'] = $comment->countCommentsByPost($posts[$k]['ID']);
         $user = new user();
         if ($posts[$k]['id_user'] < 2) {
             $posts[$k]['autor'] = $user->find(1);
         } else {
             $posts[$k]['autor'] = $user->find($posts[$k]['id_user']);
         }
     }
     $this->registry->posts = $posts;
     $this->plugin->call("index_post_content");
     $this->themes->posts = $this->registry->posts;
     $this->themes->title_for_layout = "{$this->conf['blog_name']} - {$tag}";
     $this->render();
 }
 private function process()
 {
     $this->commonProcess();
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     $mail = services::getService('mail');
     $geo = services::getService('geoinfo');
     $categories = services::getService('cats');
     if ($params->getParam('add_to_adressbook')) {
         $addr = new adressbook();
         $addr->sender_id = $this->user->id;
         $addr->recipient_id = $params->getParam('showmember');
         if (!$addr->find()) {
             $addr->insert();
             $this->addMsg('msg_adressbook_add_success');
         } else {
             $this->addMsg('msg_adressbook_add_allready');
         }
     }
     // build userlist
     // assotiativ array with object and detail-flag
     $smember = new user();
     $smember->id = $params->getParam('showmember');
     $smember->find(true);
     $member = array("obj" => $smember);
     $this->member = $member;
     $this->member['obj']->getPhoto();
     $this->geodist = $geo->getDistance($this->user, $this->member["obj"]);
 }
Exemplo n.º 4
0
 /**
  * Handle a POST request to reset a user's password.
  *
  * @return Response
  */
 public function postReset()
 {
     $credentials = Input::only('email', 'password', 'token');
     //hack password_confirmation for package
     $credentials['password_confirmation'] = $credentials['password'];
     $rules = array('email' => 'required|email', 'password' => 'required|min:6', 'token' => 'required');
     $v = Validator::make($credentials, $rules);
     if ($v->fails()) {
         return Output::push(array('path' => 'password/reset', 'errors' => $v, 'input' => TRUE));
     }
     //new style
     $validtoken = $this->_isValidToken($credentials['email'], $credentials['token']);
     if ($validtoken) {
         $id = $this->_getUserId($credentials['email']);
         if ($id) {
             $user = user::find($id);
             //$user->username = $input['username'];
             $user->email = $credentials['email'];
             if ($credentials['password']) {
                 $user->password = Hash::make($credentials['password']);
                 Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2)));
             }
             $user->save();
             return Output::push(array('path' => 'login', 'messages' => array('success' => _('Password has been reset'))));
         } else {
             return Output::push(array('path' => 'password/recovery', 'messages' => array('fail' => _('Unable to process password reset'))));
         }
     } else {
         return Output::push(array('path' => 'password/recovery', 'messages' => array('fail' => _('Invalid token'))));
     }
 }
Exemplo n.º 5
0
 public static function substractCredit($price)
 {
     $user = user::find(Auth::user()->id);
     $user_credit = $user->balance;
     $user->balance = $user_credit - $price;
     $user->save();
 }
Exemplo n.º 6
0
 public function login($msg = null)
 {
     if ($this->session->check("logged") == true) {
         $this->redirect("admin");
     }
     if ($msg == "nosession") {
         $this->session->flash("La URL solicitada necesita autentificacion.");
     } elseif ($msg == "fail") {
         $this->session->flash("Lo siento, la informacion ingresada es incorrecta.");
     } elseif ($msg == "logout") {
         $this->session->flash("Haz terminado la sesion correctamente.");
     }
     if ($this->data) {
         $U = new user();
         if ($id_user = $U->validateLogin($this->data)) {
             $user = $U->find($id_user);
             $this->session->user = $user;
             $this->session->logged = true;
             $this->redirect("admin/");
         } else {
             $this->redirect("admin/login/fail/");
         }
     } else {
         $this->view->setLayout("admin");
         $this->title_for_layout("Login - Codice CMS");
         $this->render();
     }
 }
Exemplo n.º 7
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::only('email', 'username', 'password');
     $rules = array('email' => 'required|email|unique:users,email,' . Auth::user()->id . ',id,deleted_at,NULL,status,' . Auth::user()->status . '');
     if ($input['password']) {
         $rules['password'] = '******';
     }
     $v = Validator::make($input, $rules);
     if ($v->fails()) {
         return Output::push(array('path' => 'user', 'errors' => $v, 'input' => TRUE));
     }
     if ($input['password'] && $id && Auth::user()->id == $id) {
         $user = user::find($id);
         //$user->username = $input['username'];
         $user->email = $input['email'];
         if ($input['password']) {
             $user->password = Hash::make($input['password']);
             Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2)));
         }
         $user->save();
         return Output::push(array('path' => 'user', 'errors' => 'Change Password Successfully', 'messages' => array('success', _('User data has been saved')), 'input' => TRUE));
     } else {
         return Output::push(array('path' => 'user', 'errors' => 'Unable to update user', 'messages' => array('fail', _('Unable to update user')), 'input' => TRUE));
     }
 }
Exemplo n.º 8
0
 public function adminNotify()
 {
     if ($this->cookie->check("id_user") and $this->cookie->id_user == 1) {
         //no notificamos a administrador de su propio comentario.
         return;
     }
     $id = $this->registry->lastCommentID;
     $Comment = new comment();
     $comment = $Comment->find($id);
     $comment['content'] = utils::nl2br($comment['content']);
     if (!defined('GESHI_VERSION')) {
         $comment['content'] = $this->comment_source_code_beautifier($comment['content'], 'addTagPRE');
     } else {
         $comment['content'] = $this->comment_source_code_beautifier($comment['content']);
     }
     $User = new user();
     $user = $User->find(1);
     $Post = new post();
     $post = $Post->find($comment['ID_post']);
     $commentsWaiting = $Comment->countCommentsByPost(null, 'waiting');
     $mailStr = "\n\t\t\t<table width=\"100%\">\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<small>\n\t\t\t\t\t\t<strong>From IP</strong>: {$comment['IP']}<br />\n\t\t\t\t\t\t<strong>URL</strong>: <a href=\"{$comment['url']}\">{$comment['url']}</a><br />\n\t\t\t\t\t\t<strong>Email</strong>: <a href=\"mailto:{$comment['email']}\">{$comment['email']}</a><br />\n\t\t\t\t\t\t<strong>DateTime</strong>: {$comment['created']}<br />\n\t\t\t\t\t</small>\n\t\t\t\t\t<hr>\n\t\t\t\t\t<strong>Author</strong>: {$comment['author']}<br />\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr><td><strong>Content</strong></td></tr>\n\t\t\t<tr><td bgcolor=\"#f7f7f7\">\n\t\t\t\t{$comment['content']}\n\t\t\t\t<hr />\n\t\t\t</td></tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tModerate comment: <a href=\"{$this->registry->path}comments/edit/{$comment['ID']}\">{$this->registry->path}comments/edit/{$comment['ID']}</a><br />\n\t\t\t\t\t\tView entry: <a href=\"{$this->registry->path}{$post['urlfriendly']}\">{$this->registry->path}{$post['urlfriendly']}</a>\n\t\t\t\t\t</p>\n\t\t\n\t\t\t\t\t<p>\n\t\t\t\t\t\tThere are {$commentsWaiting} comments waiting for approbal. <br />\n\t\t\t\t\t\tPlease moderate comments: <a href=\"{$this->registry->path}comments/waiting\">{$this->registry->path}comments</a>\n\t\t\t\t\t</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t</table>\n\t\t";
     $conf = $this->registry->conf;
     $subject = "[{$conf['blog_name']}] Nuevo Comentario en: {$post['title']}";
     $this->enviaMail($user['email'], $subject, $mailStr, $user['email']);
 }
Exemplo n.º 9
0
 public function page()
 {
     $page_params = services::getService('pageParams');
     $config = services::getService('config');
     $login = $page_params->getParam('login');
     $password = $page_params->getParam('password');
     $this->act_page = $page_params->getParam('page');
     $this->act_get = $this->getActGet();
     if ($login != "" && $password != "") {
         $user = new user($login, crypt($password, 'dl'));
         if ($user->find(true)) {
             $this->user = $user;
         }
     }
     // set interface-language
     // if lang is in get, a cookie is set, lang in get is set, is written in db
     // else if lang is in db, a cookie is set
     // else if lang is in cookie, lang in cookie is set, is written in db
     // else if lang is in browser, a cookie is set etc., is written in db
     // else if lang is in config.ini, cookie, set, written in db
     if ($_GET['lang']) {
         setcookie('language', $_GET['lang'], time() + 60 * 60 * 24 * 365);
         if (is_object($user)) {
             $this->user->language = $_GET['lang'];
             $this->user->update();
         }
     } else {
         if ($this->user->language) {
             if ($_COOKIE['language'] != $this->user->language) {
                 setcookie('language', $this->user->language, time() + 60 * 60 * 24 * 365);
             }
         } else {
             if ($_COOKIE['language']) {
                 if (is_object($user)) {
                     $this->user->language = $_COOKIE['language'];
                     $this->user->update();
                 }
             } else {
                 if (is_array(parseHttpAcceptLanguage())) {
                     $blang = parseHttpAcceptLanguage();
                     setcookie('language', $blang[0]['code'], time() + 60 * 60 * 24 * 365);
                     if (is_object($user)) {
                         $this->user->language = $blang[0]['code'];
                         $this->user->update();
                     }
                 } else {
                     setcookie('language', $config->getSetting('language'), time() + 60 * 60 * 24 * 365);
                     if (is_object($user)) {
                         $this->user->language = $config->getSetting('language');
                         $this->user->update();
                     }
                 }
             }
         }
     }
     $this->addMsg($page_params->getParam('msg'));
     $this->assignAll();
 }
Exemplo n.º 10
0
 public static function validateLogin($email, $password)
 {
     if ($user = user::find(array('email' => $email))) {
         if (authentication::verify($password, $user["password"])) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 11
0
 function showall($username = null)
 {
     using('lepton.user.*');
     using('lepton.mvc.request');
     if ($username) {
         $ur = user::find($username);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'Username', $ur->username);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'Displayname', $ur->displayname);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'E-Mail', $ur->email);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'UUID', $ur->uuid);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'Flags', $ur->flags);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'Active', $ur->active == 1 ? 'Yes' : 'No');
         console::writeLn(__astr('\\b{%-20s}: %s'), 'Firstname', $ur->firstname);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'Lastname', $ur->lastname);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'Last login', $ur->lastlogin);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'Last IP', $ur->lastip);
         console::writeLn(__astr('\\b{%-20s}: %s'), 'Registered', $ur->registered);
         foreach ($ur as $af => $ad) {
             console::writeLn(__astr('\\g{%-20s}: %s'), $af, $ad);
         }
     } else {
         console::writeLn("Use: user show username");
     }
 }
Exemplo n.º 12
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $detail = table_users_detail::where('users_id', '=', $id)->first();
     if (isset($detail->users_detail_id)) {
         $idusersdetail = $detail->users_detail_id;
         table_users_detail::find($idusersdetail)->delete();
     }
     user::find($id)->delete();
     return redirect('admin/users-detail')->with('warning', 'Data have been removed!');
 }
Exemplo n.º 13
0
 /**
  * Find a user in the database. Deprecated in favor of User::find()
  *
  * @deprecated since 1.0.0
  * @param string $username
  * @return UserRecord The user record if any. Null otherwise.
  */
 static function findUser($username)
 {
     __deprecated('user::findUser', 'user::find');
     return user::find($username);
 }
Exemplo n.º 14
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::only('first_name', 'last_name', 'email', 'website', 'username', 'password');
     $domain_id = Request::segment(4) ? Request::segment(4) : 'NULL';
     $rules = array('first_name' => 'required|min:1', 'email' => 'required|email|unique:users,email,' . $id . ',id,deleted_at,NULL,domain_id,' . $domain_id, 'password' => 'min:6');
     $v = Validator::make($input, $rules);
     if ($v->fails()) {
         return Output::push(array('path' => 'users/edit/' . $id, 'errors' => $v, 'input' => TRUE));
     }
     $profile = Profile::find($id);
     $profile->first_name = $input['first_name'];
     $profile->last_name = $input['last_name'];
     $profile->website = $input['website'];
     $profile->save();
     $user = user::find($id);
     //$user->username = $input['username'];
     $user->email = $input['email'];
     if ($input['password']) {
         $user->password = Hash::make($input['password']);
         Event::fire('logger', array(array('account_password_update', array('id' => $id, 'username' => $user->username), 2)));
     }
     $user->profile()->associate($profile);
     $user->save();
     $path = Request::segment(4) ? 'domain/users/' . Request::segment(4) : 'users';
     $path = Request::segment(1) == "managers" ? "managers" : $path;
     if ($id) {
         return Output::push(array('path' => $path, 'messages' => array('success' => _('You have updated user successfully'))));
     } else {
         return Output::push(array('path' => 'users/edit/' . $id, 'messages' => array('fail' => _('Fail to update user')), 'input' => TRUE));
     }
 }
Exemplo n.º 15
0
    public function putfollowinotherprofile()
    {
        $followerid = $_GET['followerid'];
        $authusrid = Auth::user()->ID;
        $curdate = date('Y-m-d h:i:s');
        $inputdetails['followerid'] = $followerid;
        $inputdetails['userid'] = $authusrid;
        $inputdetails['createddate'] = $curdate;
        $followers = followModel::create($inputdetails);
        if ($followers) {
            ////// Send Mail /////////
            $followedetails = user::find($followerid);
            $email = $followedetails['email'];
            if (Auth::user()->firstname != '') {
                $username = Auth::user()->firstname . ' ' . Auth::user()->lastname;
            } else {
                $username = Auth::user()->username;
            }
            if ($followedetails['firstname'] != '') {
                $followingusername = $followedetails['firstname'] . ' ' . $followedetails['lastname'];
            } else {
                $followingusername = $followedetails['username'];
            }
            //$email ='*****@*****.**';
            Mail::send([], array('followingusername' => $followingusername, 'email' => $email, 'username' => $username), function ($message) use($followingusername, $email, $username) {
                /* $mail_body = 'Dear {followingusername},<br><br> The Member {username} is following you.<br><br> Thank You, <br><br>Regards,<br>DingDatt<br><a href="'.URL::to('assets/inner/img/DingDatt_logo_web1.png').'" style="dislay:block;outline: none; padding:25px;margin:25px; min-height:110px; width:100%; overflow:hidden;">
                        <img src="'.URL::to('assets/inner/img/DingDatt_logo_web1.png').'" width="110" height="86" style="width:110px; padding:0px; margin:0px;" alt="DingDatt"/>
                        </a>';
                        $mail_body = str_replace("{username}", $username, $mail_body);
                		$mail_body = str_replace("{followingusername}", $followingusername, $mail_body); */
                $mail_body = '<style>.thank{text-align:center; width:100%;}
					.but_color{color:#ffffff;}
					.cont_name{width:100px;}
					.cont_value{width:500px;}
					
					</style>
			 <body style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif; margin:0px auto; padding:0px;">

				<div style="margin:0px auto;background:#e5e5e5;float:left;	width:98%;	height:30px;margin:0px 1%;  border-bottom:#005377 1px solid;vertical-align: text-middle;">
					&nbsp;&nbsp;<a href="' . URL() . '"><img src="' . URL::to('assets/images/logo.png') . '" style="margin-top:3px; line-height:20px;" /></a>&nbsp;&nbsp;
				</div>
				<div style="background:#ffffff;float:left;padding:10px 20px;margin:1px 1%;" >
					<div class="thank" style="font-size:16px;color: #078AC2;font-weight:bold;float:left;width:100%;margin-top:10px;text-align:left;">Dear ' . $followingusername . '</div>
					
					<div style="font-size:12px;	color: #000000;	float:left;padding:10px 2px;width:100%;margin:15px;">The Member.' . $username . '. is following you.
			 </div>
					
					<div style="margin:10px;"><a href="' . URL() . '"><img src="' . URL::to('assets/inner/images/vist_dingdatt.png') . '" width="120" height="30" /></a>
					</div>
				</div>
											
				<div style="font-size:12px; margin-top:10px;color: #5b5b5b;/*	background:#e5e5e5;*/width:95%;vertical-align: text-middle;height:30px;margin:0% 1%;padding:0px 15px; border-top:#005377 1px solid; border-bottom:5px solid background:#e5e5e5;line-height:25px; ">
				
				</body>';
                $message->setBody($mail_body, 'text/html');
                $message->to($email);
                $message->subject('Follower details - DingDatt');
            });
        }
        return Redirect::to("other_profile/" . $followerid)->with('Massage', 'You are following ' . $followingusername);
    }
Exemplo n.º 16
0
 function removeAccount()
 {
     $userId = Session::get('user_id');
     if (!isset($userId)) {
         return json_encode(array('message' => 'not logged'));
     }
     if (isset($userId)) {
         $user = user::find($userId);
         if (isset($user)) {
             $user->status = 'removed';
             $user->save();
             return json_encode(array('message' => 'done'));
         } else {
             return json_encode(array('message' => 'invalid'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
} else {
    $casesIds = CaseOwner::where('user', '=', \Auth::user()->id)->get();
    $ids = array();
    foreach ($casesIds as $case) {
        $ids[] = $case->caseId;
    }
    $cases = CaseReport::whereNotNull('gps_lat')->whereNotNull('gps_lng')->whereIn('id', $ids)->get();
}
foreach ($cases as $case) {
    if ($case->addressbook == 1) {
        $userObj = addressbook::find($case->reporter);
        $ReporterName = $userObj->FirstName . ' ' . $userObj->Surname;
        $ReporterPosition = "";
        $ReporterMobile = $userObj->cellphone;
    } else {
        $userObj = user::find($case->reporter);
        $ReporterName = $userObj->name . ' ' . $userObj->surname;
        $RepPos = Position::find($userObj->position);
        $ReporterPosition = $RepPos->name;
        $ReporterMobile = $userObj->email;
    }
    $user = User::find($case->user);
    $position = Position::find($user->position);
    $ID = $case->id;
    $GPS = $case->gps_lat . ',' . $case->gps_lng;
    $Province = 'KZN';
    $Port = Municipality::find($case->precinct);
    $Port = $Port->name;
    $precinctObj = Municipality::find($case->precinct);
    $Precinct = $precinctObj->name;
    $Submitted = $case->created_at;
Exemplo n.º 18
0
 /**
  * Show the form for editing the specified user.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = user::find($id);
     return View::make('users.edit', compact('user'));
 }
Exemplo n.º 19
0
 function cupdate($id = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         $_POST = array_map('htmlspecialchars', $_POST);
         $quotation = Quoterequest::find_by_id($id);
         $quotation = $quotation->update_attributes($_POST);
         if (!$quotation) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_quotation_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_quotation_success'));
         }
         redirect('quotations/cview/' . $id);
     } else {
         $this->view_data['quotations'] = Quoterequest::find_by_id($id);
         $this->view_data['users'] = user::find('all', array('conditions' => array('status=?', 'active')));
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_edit_quotation');
         $this->view_data['form_action'] = 'quotations/cupdate/' . $id;
         $this->content_view = 'quotations/_quotations';
     }
 }
Exemplo n.º 20
0
	
	$('#notVerified').hide();
</script>

</body>
</html>
<?php 
if ($input == true) {
    if ($token == true) {
        $validate = new validate();
        $validation = $validate->check($_POST, array('Username' => array('required' => true)));
        if ($validation->passed()) {
            $user = new user(null, $_log);
            $remember = input::get('remember') === 'on' ? true : false;
            $login = $user->login(input::get('Username'), input::get('Password'), $remember);
            if ($user->verified(input::get('Username')) && $user->find(input::get('Username'))) {
                if ($login) {
                    redirect::to('../index.php');
                }
            } else {
                echo "<script type='text/javascript'> notVerifiedShow(); </script>";
            }
            // else {
            // 	echo 'Sorry, logging in failed';
            // }
        } else {
            foreach ($validation->errors() as $error) {
                echo $error, '<br>';
            }
        }
    } else {
Exemplo n.º 21
0
/**
 * Gets a instructor listing with specific sort and other filters.
 *
 * @param string $sort Field to sort on.
 * @param string $dir Direction of sort.
 * @param int $startrec Record number to start at.
 * @param int $perpage Number of records per page.
 * @param string $namesearch Search string for instructor name.
 * @param string $alpha Start initial of instructor name filter.
 * @return object array Returned records.
 */
function user_get_listing($sort = 'name', $dir = 'ASC', $startrec = 0, $perpage = 0, $namesearch = '', $alpha = '')
{
    global $DB;
    $FULLNAME = $DB->sql_concat_join("' '", array('firstname', 'lastname'));
    $filters = array();
    if (!empty($namesearch)) {
        $namesearch = trim($namesearch);
        $filters[] = new field_filter($FULLNAME, "%{$DB->sql_like_escape($namesearch)}%", field_filter::LIKE);
    }
    if ($alpha) {
        $filters[] = new field_filter($FULLNAME, "{$DB->sql_like_escape($alpha)}%", field_filter::LIKE);
    }
    if ($sort) {
        $sort = array($sort, $dir);
    } else {
        $sort = array();
    }
    return user::find(new AND_filter($filters), $sort, $startrec, $perpage);
}
Exemplo n.º 22
0
/**
 * Migrate a single Moodle user to the Program Management system.  Will
 * only do this for users who have an idnumber set.
 *
 * @param object $mu Moodle user object
 * @return boolean Whether user was synchronized or not
 */
function pm_moodle_user_to_pm($mu)
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/lib/moodlelib.php';
    require_once elis::lib('data/customfield.class.php');
    require_once elispm::lib('data/user.class.php');
    require_once elispm::lib('data/usermoodle.class.php');
    require_once elis::lib('data/data_filter.class.php');
    require_once $CFG->dirroot . '/user/profile/lib.php';
    require_once elis::lib('lib.php');
    if (!isset($mu->id)) {
        return true;
    }
    // re-fetch, in case this is from a stale event
    $mu = $DB->get_record('user', array('id' => $mu->id));
    if (user_not_fully_set_up($mu) || !$mu->confirmed) {
        // Prevent the sync if a bare-bones user record is being created by create_user_record
        // or Moodle user has not yet been confirmed.
        return true;
    }
    //not going to be concerned with city or password for now
    if (empty($mu->idnumber) && elis::$config->local_elisprogram->auto_assign_user_idnumber) {
        //make sure the current user's username does not match up with some other user's
        //idnumber (necessary since usernames and idnumbers aren't bound to one another)
        if (!$DB->record_exists('user', array('idnumber' => $mu->username))) {
            $mu->idnumber = $mu->username;
            $DB->update_record('user', $mu);
        }
    }
    // skip user if no ID number set
    if (empty($mu->idnumber)) {
        return true;
    }
    // track whether we're syncing an idnumber change over to the PM system
    $idnumber_updated = false;
    // track whether an associated Moodle user is linked to the current PM user
    $moodle_user_exists = false;
    // determine if the user is already noted as having been associated to a PM user
    // this will join to Moodle user and PM user table to ensure data correctness
    $filters = array();
    $filters[] = new join_filter('muserid', 'user', 'id');
    $filters[] = new join_filter('cuserid', user::TABLE, 'id');
    $filters[] = new field_filter('muserid', $mu->id);
    if ($um = usermoodle::find($filters)) {
        if ($um->valid()) {
            $um = $um->current();
            //signal that an associated user already exists
            $moodle_user_exists = true;
            // determine if the Moodle user idnumber was updated
            if ($um->idnumber != $mu->idnumber) {
                //signal that the idnumber was synced over
                $idnumber_updated = true;
                // update the PM user with the new idnumber
                $cmuser = new user();
                $cmuser->id = $um->cuserid;
                $cmuser->idnumber = $mu->idnumber;
                $cmuser->save();
                // update the association table with the new idnumber
                $um->idnumber = $mu->idnumber;
                $um->save();
            }
        }
    }
    // find the linked PM user
    //filter for the basic condition on the Moodle user id
    $condition_filter = new field_filter('id', $mu->id);
    //filter for joining the association table
    $association_filter = new join_filter('muserid', 'user', 'id', $condition_filter);
    //outermost filter
    $filter = new join_filter('id', usermoodle::TABLE, 'cuserid', $association_filter);
    $cu = user::find($filter);
    if ($cu->valid()) {
        $cu = $cu->current();
    } else {
        // if a user with the same username but different idnumber exists,
        // we can't sync over because it will violate PM user uniqueness
        // constraints
        $cu = user::find(new field_filter('username', $mu->username));
        if ($cu->valid()) {
            return true;
        }
        // if no such PM user exists, create a new one
        $cu = new user();
        $cu->transfercredits = 0;
        $cu->timecreated = time();
    }
    // synchronize standard fields
    $cu->username = $mu->username;
    $cu->password = $mu->password;
    // only need to update the idnumber if it wasn't handled above
    if (!$idnumber_updated) {
        $cu->idnumber = $mu->idnumber;
    }
    $cu->firstname = $mu->firstname;
    $cu->lastname = $mu->lastname;
    $cu->email = $mu->email;
    $cu->address = $mu->address;
    $cu->city = $mu->city;
    $cu->country = $mu->country;
    if (!empty($mu->phone1)) {
        $cu->phone = $mu->phone1;
    }
    if (!empty($mu->phone2)) {
        $cu->phone2 = $mu->phone2;
    }
    if (!empty($mu->lang)) {
        $cu->language = $mu->lang;
    }
    $cu->timemodified = time();
    // synchronize custom profile fields
    profile_load_data($mu);
    fix_moodle_profile_fields($mu);
    $fields = field::get_for_context_level(CONTEXT_ELIS_USER);
    $fields = $fields ? $fields : array();
    require_once elis::plugin_file('elisfields_moodleprofile', 'custom_fields.php');
    foreach ($fields as $field) {
        $field = new field($field);
        if (!moodle_profile_can_sync($field->shortname)) {
            continue;
        }
        if (isset($field->owners['moodle_profile']) && isset($mu->{"profile_field_{$field->shortname}"})) {
            // check if should sync user profile field settings
            if ($field->owners['moodle_profile']->exclude == pm_moodle_profile::sync_from_moodle) {
                sync_profile_field_settings_from_moodle($field);
            }
            $fieldname = "field_{$field->shortname}";
            $cu->{$fieldname} = $mu->{"profile_field_{$field->shortname}"};
        }
    }
    //specifically tell the user save not to use the local_elisprogram_usr_mdl for syncing
    //because the record hasn't been inserted yet (see below)
    try {
        $cu->save(false);
    } catch (Exception $ex) {
        if (in_cron()) {
            mtrace(get_string('record_not_created_reason', 'local_elisprogram', array('message' => $ex->getMessage() . " [{$mu->id}]")));
            return false;
        } else {
            throw new Exception($ex->getMessage());
        }
    }
    // if no user association record exists, create one
    if (!$moodle_user_exists) {
        $um = new usermoodle();
        $um->cuserid = $cu->id;
        $um->muserid = $mu->id;
        $um->idnumber = $mu->idnumber;
        $um->save();
    }
    return true;
}
Exemplo n.º 23
0
use yii\helpers\ArrayHelper;
use dektrium\user\models\User;
use backend\models\Relevadores;
/* @var $this yii\web\View */
/* @var $model backend\models\Relevadores */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="relevadores-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
$usuarios = ArrayHelper::map(user::find()->all(), 'id', 'username');
?>
    <?php 
$relevadores = ArrayHelper::toArray(Relevadores::find()->all());
?>



    <?php 
unset($usuarios['1']);
?>
    
    <?php 
foreach ($relevadores as $value) {
    if (!in_array($value['idUsuario'], $usuarios, true)) {
        unset($usuarios[$value['idUsuario']]);
Exemplo n.º 24
0
 public function user()
 {
     return user::find($this->created_by, array('select' => 'username', 'readonly' => true));
 }
Exemplo n.º 25
0
 function get_records_from_selection($record_ids)
 {
     $sort = $this->optional_param('sort', 'name', PARAM_ALPHA);
     $dir = $this->optional_param('dir', 'ASC', PARAM_ALPHA);
     $perpage = $this->optional_param('perpage', 30, PARAM_INT);
     $page = $this->optional_param('page', 0, PARAM_INT);
     $users = user::find(new in_list_filter('id', $record_ids), array($sort => $dir), $page * $perpage, $perpage);
     return $users;
 }
Exemplo n.º 26
0
 /**
  *This function will handle the post requests
  *
  * 
  * Tasks
  *	1. Load Opend Tickets
  *	2. Load Closed Tickets 
  *	3. Close the tickets
  *	4. Open the tickets
  * 
  **/
 public function inputs()
 {
     if (Request::get('task') == "loadtableopendtickets") {
         $x = Request::get('skip');
         return $this->loadTableOpendTickets($x);
     } elseif (Request::get('task') == "loadtableclosedtickets") {
         $x = Request::get('skip');
         return $this->loadTableClosedTickets($x);
     } elseif (Request::get('task') == "closeTicket") {
         $ids = Request::get('tickets');
         return $this->closeTickets($ids);
     } elseif (Request::get('task') == "openTicket") {
         $ids = Request::get('tickets');
         return $this->openTickets($ids);
     } elseif (Request::get('task') == "viewTicket") {
         $user = Session::get('user');
         $ids = Request::get('ticket');
         if (!is_null($ids)) {
             $ticket = tickets::find($ids);
             if (is_null($ticket)) {
                 abort(404);
             }
             if ($ticket->userid != Session::get('userid') && $user->level < 10) {
                 abort(404);
             }
             $admin = adminUserTickets::where('ticketid', $ticket->id)->first();
             $staff = null;
             if (!is_null($admin)) {
                 $staff = user::find($admin->adminid);
             }
             $ticketsMessages = tickets_messages::where('ticket_id', $ticket->id)->orderBy('id', 'asc')->get();
             return view('user.tickets.reply')->with('user', $user)->with('messages', $ticketsMessages)->with('ticket', $ticket)->with('staff', $staff);
         } else {
             abort(404);
         }
     } elseif (Request::get('task') == "replyTickets") {
         $message = Request::get('text');
         $ticket_id = Request::get('ticket_id');
         return $this->replyTickets($message, $ticket_id);
     }
 }
Exemplo n.º 27
0
 function remove($userId)
 {
     if (isset($userId)) {
         $user = user::find($userId);
         if (isset($user)) {
             $user->status = 'removed';
             $user->save();
             return json_encode(array('message' => 'done'));
         } else {
             return json_encode(array('message' => 'invalid'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
Exemplo n.º 28
0
 /**
  * Remove the specified resource from storage.
  * DELETE /users/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $user = user::find($id);
     if (is_null($user)) {
         $class = 'error';
         $message = 'Record does not exist.';
     } else {
         $user = User::find($id);
         $user->active = 0;
         $user->save();
         $class = 'success';
         $message = 'Record successfully inactivate.';
     }
     return Redirect::route('user.index')->with('class', $class)->with('message', $message);
 }
Exemplo n.º 29
0
 /**
  * Test PM user method moodle_fullname
  */
 public function test_pmuser_moodle_fullname()
 {
     global $DB;
     // Create a Moodle user
     $src = new stdClass();
     $src->username = '******';
     $src->password = '******';
     $src->idnumber = '_____phpunit_test_';
     $src->firstname = 'John';
     $src->lastname = 'Doe';
     $src->email = '*****@*****.**';
     $src->country = 'CA';
     $src->confirmed = 1;
     $src->id = $DB->insert_record('user', $src);
     events_trigger('user_created', $src);
     // Get the PM user
     $retr = user::find(new field_filter('idnumber', $src->idnumber), array(), 0, 0);
     $this->assertTrue($retr->valid());
     $retr = $retr->current();
     $mdluser = $DB->get_record('user', array('id' => $src->id));
     $this->assertEquals(fullname($mdluser), $retr->moodle_fullname());
 }
function emailUnique($email)
{
    $check_user = new user();
    $check_user->email = $email;
    if ($check_user->find()) {
        return false;
    } else {
        return true;
    }
}