public function get_message_info($passed_id = '', $param = '') { //if NO ID if ($passed_id == '') { return NULL; } else { //get user info $query = $this->db->select()->from($this->_tablename)->where($this->_primary_key, $passed_id)->get(); if ($query->result_array()) { foreach ($query->result_array() as $row) { //filter results switch ($param) { case 'sender_id': $result = $row['sender_id']; break; case 'sender': $result = get_user_info_by_id($row['sender_id'], 'fullname'); break; case 'reciepient_id': $result = $row['reciepient_id']; break; case 'reciepient': $result = get_user_info_by_id($row['reciepient_id'], 'fullname'); break; case 'dateseen': $result = $row['dateseen']; break; case 'dateadded': $result = $row['dateadded']; break; case 'content': $result = $row['content']; break; case 'view_status': $result = $row['view_status']; break; default: $result = $query->result_array(); } } return $result; } } }
function logged_in_user($param) { $ci =& get_instance(); switch ($param) { //get id case 'id': $result = $ci->session->userdata('logged_in_user_id'); break; //get firstname //get firstname case 'firstname': $result = get_user_info_by_id($ci->session->userdata('logged_in_user_id'), 'firstname'); break; //get lastname //get lastname case 'lastname': $result = get_user_info_by_id($ci->session->userdata('logged_in_user_id'), 'lastname'); break; //get fullname //get fullname case 'fullname': $result = get_user_info_by_id($ci->session->userdata('logged_in_user_id'), 'firstname') . ' ' . get_user_info_by_id($ci->session->userdata('logged_in_user_id'), 'lastname'); break; //get email //get email case 'email': $result = get_user_info_by_id($ci->session->userdata('logged_in_user_id'), 'email'); break; //get usertype //get usertype case 'usertype': $result = get_user_info_by_id($ci->session->userdata('logged_in_user_id'), 'user_type'); break; case 'usertype_id': $result = get_user_info_by_id($ci->session->userdata('logged_in_user_id'), 'usertype_id'); break; //get avatar //get avatar case 'avatar': $result = get_user_info_by_id($ci->session->userdata('logged_in_user_id'), 'avatar'); break; default: $result = get_user_info_by_id($ci->session->userdata('logged_in_user_id'), ''); } return $result; }
function send_notice_mail($data) { if (intval(kget('sendcloud_on')) != 1) { return false; } // 未设置,或者设置为接受 // 检查是否在线 // 只有不在线的时候发送邮件通知 $send = true; /* if( intval( kget('mqueue_not_online') ) == 1 && is_online( $data['uid'] ) ) $send = false; */ if ($send) { $user = get_user_info_by_id($data['uid']); $dd = array(); $dd['to'] = $email = $user['email']; $dd['subject'] = __('PL_SENDCLOUD_NOTICE_MAIL_TITLE', array(c('site_name'), mb_strimwidth($data['content'], 0, 20, '...', 'UTF-8'))); $dd['body'] = $data['content'] . __('PL_SENDCLOUD_NOTICE_MAIL_CONTENT_POSTFIX', c('site_url') . '/?c=inbox'); sendcloud_mail($dd['to'], $dd['subject'], $dd['body']); } }
public function checklocation() { //$token = z(t(v('token'))); $latitude = t(v('latitude')); $longitude = z(t(v('longitude'))); $username = z(t(v('username'))); /*$barcodevalue = "abcdefg"; $barcodeformat = "hijklmn"; $username = "******";*/ //$remember = v('remember'); //$sql = "SELECT * FROM `user` WHERE `email` = '" . s( $email ) . "' AND `password` = '" . md5( $password ) . "' AND `status` = 'OK' LIMIT 1"; $user = get_user_info_by_id($username); if ($user) { if (floatval($latitude) - floatval($user['latitude']) < 0.001 && floatval($latitude) - floatval($user['latitude']) > -0.001 && floatval($longitude) - floatval($user['longitude']) < 0.002 && floatval($longitude) - floatval($user['longitude']) > -0.002) { return $this->send_result(array('arrived' => 'confirmed')); } else { return $this->send_result(array('arrived' => 'negative')); } } else { return $this->send_error(OP_API_TOKEN_ERROR, "地址获取失败!"); } }
function stoken_api_login($data) { $stoken = z(t(v('stoken'))); if (!in_array(g('a'), $data) && strlen($stoken) > 0) { if ($uid = get_var("SELECT `uid` FROM `stoken` WHERE `token` = '" . s($stoken) . "' AND `on` = '1' LIMIT 1")) { $user = get_user_info_by_id($uid); if ($user['level'] < 1 || $user['is_closed'] == 1) { return apiController::send_error(LR_API_USER_CLOSED, 'USER CLOSED BY ADMIN'); } session_set_cookie_params(c('session_time')); @session_start(); $token = session_id(); // $_SESSION[ 'token' ] = $stoken; <- 加上这行stoken可以变成token $_SESSION['uid'] = $user['id']; $_SESSION['uname'] = $user['name']; $_SESSION['email'] = $user['email']; $_SESSION['level'] = $user['level']; $data[] = g('a'); } } return $data; }
function todo_flow_item() { $uid = intval(z(v(t('uid')))); if ($uid < 0) { return ajax_echo('BAD UID'); } $params = array(); $params['uid'] = $uid; $params['ord'] = 'desc'; $params['by'] = 'last_action_at'; $params['count'] = '20'; if ($content = send_request('todo_list', $params, token())) { $data = json_decode($content, 1); $data['user'] = get_user_info_by_id($uid); if (isset($data['data'])) { foreach ($data['data'] as $k => $v) { if ($v['is_follow'] == 1) { unset($data['data'][$k]); } } } return render($data, 'ajax', 'plugin', 'todo_flow'); } }
/** * 用户更新头像 * * 使用标准Form表单上传,头像文件名为file,只接受jpg格式的文件 * * @param string token , 必填 * @return user array * @author EasyChen */ public function user_update_avatar() { if ($_FILES['file']['error'] != 0) { return self::send_error(OP_API_UPLOAD_ERROR, 'UPLOAD ERROR ' . $_FILES['file']['error']); } $tmp_image_name = SAE_TMP_PATH . md5(time() . rand(1, 99999)) . '.tmp.jpg'; jpeg_up($_FILES['file']['tmp_name'], $tmp_image_name); include_once AROOT . 'lib/thumbnail.class.php'; $file_thumb_name = 'avatar-' . uid() . '.jpg'; $tmp_file = SAE_TMP_PATH . $file_thumb_name; include_once AROOT . 'lib/icon.class.php'; $icon = new Icon(); $icon->path = $tmp_image_name; $icon->size = 100; $icon->dest = $tmp_file; $icon->createIcon(); if (on_sae()) { $s = new SaeStorage(); if (!($thumb_url = $s->write('upload', $file_thumb_name, file_get_contents($tmp_file)))) { return self::send_error(OP_API_STORAGE_ERROR, 'SAVE ERROR ' . $s->errmsg()); } } else { $local_storage = AROOT . 'static' . DS . 'upload' . DS . 'avatar' . DS; $local_storage_url = c('site_url') . DS . 'static' . DS . 'upload' . DS . 'avatar' . DS; $thumb_path = $local_storage . $file_thumb_name; $thumb_url = $local_storage_url . $file_thumb_name; if (!copy($tmp_file, $thumb_path)) { return self::send_error(OP_API_STORAGE_ERROR, 'SAVE ERROR '); } } $sql = "UPDATE `user` SET `avatar_small` = '" . s($thumb_url) . "' WHERE `id` = '" . intval(uid()) . "' LIMIT 1"; run_sql($sql); if (mysql_errno() != 0) { return self::send_error(OP_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . mysql_error()); } else { return self::send_result(get_user_info_by_id(intval(uid()))); } }
function send_notice_mail($data) { if (intval(kget('mqueue_on')) != 1) { return false; } if (intval(kget('mqueue_usettings_' . $data['uid'])) == 1) { // 未设置,或者设置为接受 // 检查是否在线 // 只有不在线的时候发送邮件通知 $send = true; if (intval(kget('mqueue_not_online')) == 1 && is_online($data['uid'])) { $send = false; } if ($send) { $user = get_user_info_by_id($data['uid']); $dd = array(); $dd['to'] = $email = $user['email']; $dd['subject'] = __('PL_MAIL_QUEUE_NOTICE_MAIL_TITLE', array(c('site_name'), mb_strimwidth($data['content'], 0, 20, '...', 'UTF-8'))); $dd['body'] = $data['content'] . __('PL_MAIL_QUEUE_NOTICE_MAIL_CONTENT_POSTFIX', c('site_url') . '/?c=inbox'); $sql = "INSERT INTO `mail_queue` ( `email` , `data` , `timeline` ) VALUES ( '" . s($email) . "' , '" . s(serialize($dd)) . "' , '" . s(date("Y-m-d H:i:s")) . "' )"; run_sql($sql); } } }
function get_users_by_group($group_id, $pde_id) { if ($pde_id == '') { return NULL; } else { //echo $pde_id; $ci =& get_instance(); $ci->load->model('role_m'); $where = array('groupid' => $group_id, 'isactive' => 'Y'); $users = array(); $users_unfiltered = array(); foreach ($ci->role_m->get_where($where) as $roles_row) { //prevent dupes if (!in_array($roles_row['userid'], $users)) { $users_unfiltered[] = $roles_row['userid']; } foreach ($users_unfiltered as $user) { //if users pdes match if (get_user_info_by_id($user, 'pde_id') == $pde_id) { //insert user id not already inserted if (!in_array($user, $users)) { $users[] = $user; } } } } //this is an array of active users by group id in a given pde return $users; } }
function send_notice_mail($data) { if (intval(kget('mqueue_on')) != 1) { return false; } if (intval(kget('mqueue_usettings_' . $data['uid'])) == 1) { // 未设置,或者设置为接受 // 检查是否在线 // 只有不在线的时候发送邮件通知 if (!is_online($data['uid'])) { $user = get_user_info_by_id($data['uid']); $dd = array(); $dd['to'] = $email = $user['email']; $dd['subject'] = c('site_name') . '邮件通知 - ' . mb_strimwidth($data['content'], 0, 20, '...', 'UTF-8'); $dd['body'] = $data['content'] . ' - <a href="' . c('site_url') . '/?c=inbox">点击这里查看详情</a>'; $sql = "INSERT INTO `mail_queue` ( `email` , `data` , `timeline` ) VALUES ( '" . s($email) . "' , '" . s(serialize($dd)) . "' , '" . s(date("Y-m-d H:i:s")) . "' )"; run_sql($sql); } } }
data-action="delete_article" data-title="Delete <?= ucwords($row['title']) ?>" data-toggle="modal" data-target="#myModal"><i class="md md-delete"></i></a> <?php } ?> <?= ucwords($row['title']) ?> <?=get_trending_item_info($row['id'] ,'blog')==TRUE?'<span class="pull-right text-success"><strong><a href="'.base_url().$this->uri->segment(1).'/admin_trending">Trending</a></strong></span>':''?> <br> <small style="margin-left: 30px;"> <?= ucwords(time_ago($row['dateadded'])) ?> | <?= ucwords(get_user_info_by_id($row['author'], 'fullname')) ?> </small> </td> <td> <?php if ($row['cover_image']) { //if there is a cover image ?> <a href="<?= base_url() . 'uploads/blogs/' . $row['cover_image'] ?>" class="fancybox" title="<?= $row['title'] ?>"> <img class="img-circle" width="32px" height="32px" src="<?= base_url() ?>uploads/blogs/<?= get_thumbnail($row['cover_image']) ?>"> </a>
?> <div class="messages messages-img"> <?php foreach ($all_my_messages_paginated as $message) { ?> <div class="item item-visible"> <div class="image"> <img src="<?= base_url() . 'uploads/avatars/' . get_user_info_by_id($message['sender_id'], 'avatar') ?>" alt="<?= get_user_info_by_id($message['sender_id'], 'fullname') ?>"> </div> <div class="text"> <div class="heading"> <a href="<?= base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/send_message/' . encryptValue($message['sender_id']) . '/reply/' . encryptValue($message['sender_id']) ?>"><?= get_user_info_by_id($message['sender_id'], 'fullname') ?></a> <span class="date"> <?= time_ago($message['dateadded']) ?></span> </div> <?= $message['content'] ?> </div> </div> <?php } ?> </div> <?php } else { echo info_template('You have no new messages');
/** * get teacher progress by course and session * @param int course id * @param int session id * @return data array */ static function get_teachers_progress_by_course($courseId, $sessionId) { $course = api_get_course_info_by_id($courseId); $sessionId = intval($sessionId); $courseId = intval($courseId); //get teachers $sql = "SELECT scu.id_session, scu.id_user, s.name\n FROM session_rel_course_rel_user scu, session s\n WHERE\n scu.id_session = s.id\n AND scu.status = 2\n AND scu.visibility = 1\n AND scu.course_code = '%s'\n AND scu.id_session = %s"; $query = sprintf($sql, $course['code'], $sessionId); $rs = Database::query($query); $teachers = array(); while ($teacher = Database::fetch_array($rs, 'ASSOC')) { $teachers[] = $teacher; } foreach ($teachers as $teacher) { //total documents added $sql = "SELECT count(*) as total\n FROM c_item_property\n WHERE lastedit_type = 'DocumentAdded'\n AND c_id = %s\n AND insert_user_id = %s\n AND id_session = %s"; $query = sprintf($sql, $courseId, $teacher['id_user'], $teacher['id_session']); $rs = Database::query($query); $totalDocuments = 0; if ($rs) { $row = Database::fetch_row($rs); $totalDocuments = $row[0]; } //total links added $sql = "SELECT count(*) as total\n FROM c_item_property\n WHERE lastedit_type = 'LinkAdded'\n AND c_id = %s\n AND insert_user_id = %s\n AND id_session = %s"; $query = sprintf($sql, $courseId, $teacher['id_user'], $teacher['id_session']); $rs = Database::query($query); $totalLinks = 0; if ($rs) { $row = Database::fetch_row($rs); $totalLinks = $row[0]; } //total forums added $sql = "SELECT count(*) as total\n FROM c_item_property\n WHERE lastedit_type = 'ForumthreadVisible'\n AND c_id = %s\n AND insert_user_id = %s\n AND id_session = %s"; $query = sprintf($sql, $courseId, $teacher['id_user'], $teacher['id_session']); $rs = Database::query($query); $totalForums = 0; if ($rs) { $row = Database::fetch_row($rs); $totalForums = $row[0]; } //total wikis added $sql = "SELECT COUNT(DISTINCT(ref)) as total\n FROM c_item_property\n WHERE lastedit_type = 'WikiAdded'\n AND c_id = %s\n AND insert_user_id = %s\n AND id_session = %s"; $query = sprintf($sql, $courseId, $teacher['id_user'], $teacher['id_session']); $rs = Database::query($query); $totalWikis = 0; if ($rs) { $row = Database::fetch_row($rs); $totalWikis = $row[0]; } //total works added $sql = "SELECT COUNT(*) as total\n FROM c_item_property\n WHERE lastedit_type = 'DirectoryCreated'\n AND tool = 'work'\n AND c_id = %s\n AND insert_user_id = %s\n AND id_session = %s"; $query = sprintf($sql, $courseId, $teacher['id_user'], $teacher['id_session']); $rs = Database::query($query); $totalWorks = 0; if ($rs) { $row = Database::fetch_row($rs); $totalWorks = $row[0]; } //total announcements added $sql = "SELECT COUNT(*) as total\n FROM c_item_property\n WHERE lastedit_type = 'AnnouncementAdded'\n AND c_id = %s\n AND insert_user_id = %s\n AND id_session = %s"; $query = sprintf($sql, $courseId, $teacher['id_user'], $teacher['id_session']); $rs = Database::query($query); $totalAnnouncements = 0; if ($rs) { $row = Database::fetch_row($rs); $totalAnnouncements = $row[0]; } $tutor = get_user_info_by_id($teacher['id_user']); $data[] = array('course' => $course['title'], 'session' => $teacher['name'], 'tutor' => $tutor['username'] . ' - ' . $tutor['lastname'] . ' ' . $tutor['firstname'], 'documents' => $totalDocuments, 'links' => $totalLinks, 'forums' => $totalForums, 'works' => $totalWorks, 'wikis' => $totalWikis, 'announcements' => $totalAnnouncements); } return $data; }
public function get_contract_info($contracts_id, $param) { //$this->db->cache_on(); $query = $this->db->select()->from($this->_tablename)->where($this->_primary_key, $contracts_id)->get(); //print_array($this->db->last_query()); $info_array = $query->result_array(); // print_array($info_array); //if there is a result if (count($info_array)) { foreach ($info_array as $row) { switch ($param) { case 'emergency_procurement': $result = $row['emergency_procurement']; break; case 'direct_procurement': $result = $row['direct_procurement']; break; case 'procurement_ref_no': $result = $row['procurement_ref_no']; break; case 'admin_review': $result = $row['admin_review']; break; case 'date_of_sg_approval': $result = $row['date_of_sg_approval']; break; case 'final_award_notice_date': $result = $row['final_award_notice_date']; break; case 'commencement_date': $result = $row['commencement_date']; break; case 'contract_amount': $result = $row['contract_amount']; break; case 'amount_currency': $result = $row['amount_currency']; break; case 'exchange_rate': $result = $row['exchange_rate']; break; case 'author_id': $result = $row['author']; break; case 'author': $result = get_user_info_by_id($row['author'], 'fullname'); break; case 'isactive': $result = $row['isactive']; break; case 'dateawarded': $result = $row['dateawarded']; break; case 'procurement_ref_id': $result = $row['procurement_ref_id']; break; default: //no parameter is passed display all user info $result = $info_array; } } return $result; } else { return NULL; } }
* Created by PhpStorm. * User: cengkuru * Date: 4/10/2015 * Time: 9:30 PM */ //print_array($results); ?> <div class="messages messages-img"> <?php foreach ($results as $result) { ?> <div class="item in item-visible"> <div class="image"> <i class="fa fa-comment 4x"> me</i> </div> <div class="text"> <div class="heading"> <a href="#"><?= get_user_info_by_id($result['sender_id'], 'fullname') ?></a> <span class="date"><?= time_ago($result['dateadded']) ?></span> </div> <?= $result['content'] ?> <br> <small style="color: #CCC">Unseen</small> </div> </div> <?php } ?> </div>
<div class="form-group"> <label class="col-md-2 control-label">Address</label> <div class="col-md-10"> <input id="address" type="text" class="form-control" placeholder="Fill in your address please" value="<?= get_user_info_by_id($id, 'address') ?>"> </div> </div> <div class="form-group"> <label class="col-md-2 control-label">Bio</label> <div class="col-md-10"> <textarea id="bio" maxlength="165" class="form-control" rows="5"><?= html_entity_decode(get_user_info_by_id($id, 'bio')) ?></textarea> </div> </div> <div class="form-group"> <label class="col-md-2 control-label"></label> <div class="col-md-10"> <div class="form-group"> <input type="submit" class="btn btn-primary register" value="Edit account"> </div> </div> </div> <div class="message">
</div> </form> </div> <div class="panel panel-info"> <div class="panel-heading ui-draggable-handle"> <h3 class="panel-title">Bio</h3> </div> <div class="panel-body"> <?= get_user_info_by_id($id, 'bio') ?> </div> </div> <div class="panel panel-info"> <div class="panel-heading ui-draggable-handle"> <h3 class="panel-title">Location</h3> </div> <div class="panel-body"> <?= get_user_location($id) ?> </div>
$('.email').click(function () { //loading gif $(".message").html('<img src="<?=base_url()?>images/loading.gif" /> Now loading...'); var subject = $('#subject').val(); var message = $('#message').val(); var form_data = { subject: subject, message: message, email: '<?=get_user_info_by_id($id,'email')?>', ajax: 'send_email_f' }; $.ajax({ url: "<?php echo site_url($this->uri->segment(1).'/'.$this->uri->segment(2).'/ajax_calls') ?>", type: 'POST', data: form_data, success: function (msg) { $('.message').html(msg); } }); return false;
public function get_procurement_plan_info($plan_id, $param) { $this->db->cache_on(); $query = $this->db->select()->from($this->_tablename)->where($this->_primary_key, $plan_id)->get(); # print_array($this->db->last_query()); # print_r($this->_tablename); exit(); $info_array = $query->result_array(); //if there is a result if (count($info_array)) { foreach ($info_array as $row) { switch ($param) { case 'financial_year': $result = $row['financial_year']; break; case 'title': $result = $row['title']; break; case 'pde_id': $result = $row['pde_id']; break; case 'pde': $result = get_pde_info_by_id($row['pde_id'], 'title'); break; case 'description': $result = $row['description']; break; case 'author_id': $result = $row['author']; break; case 'author': $result = get_user_info_by_id($row['author'], 'fullname'); break; case 'isactive': $result = $row['active']; break; case 'dateadded': $result = $row['dateadded']; break; default: //no parameter is passed display all user info $result = $info_array; } } return $result; } else { return NULL; } }
function full_report() { //check if person is authorised to view report //load view variables if (get_user_info_by_id($this->session->userdata('userid'), 'pde_id') == get_procurement_plan_entry_info(decryptValue($this->uri->segment(4)), 'pde_id')) { $data['page_title'] = get_procurement_plan_entry_info(decryptValue($this->uri->segment(4)), 'title'); $data['current_menu'] = 'view_procurement_plans'; $data['entry_id'] = decryptValue($this->uri->segment(4)); $data['view_to_load'] = 'procurement/admin/entry_report_v'; $data['view_data']['form_title'] = $data['page_title']; //echo get_procurement_plan_entry_info(decryptValue($this->uri->segment(5)), 'title'); //load view $this->load->view('dashboard_v', $data); } else { //load view variables $data['page_title'] = "Oops"; $data['current_menu'] = 'dashboard'; $data['view_to_load'] = 'error_pages/500_v'; $data['view_data']['form_title'] = $data['page_title']; $data['message'] = 'Only authorised PDU members can view this page'; //load view $this->load->view('dashboard_v', $data); } }
if($row['tags']){ foreach(pipes_to_array($row['tags']) as $tag){ ?> <span class="label label-default"><?=get_tag_info($tag,'title')?></span> <?php } } ?> </div> </a> <br> <small> <?=ucwords(time_ago($row['dateadded']))?> | <?=ucwords(get_user_info_by_id($row['author'],'fullname'))?> </small> </td> </tr> <?php } ?> </tbody> </table> </div><!--end .card-body --> </div>
public function user_verify() { //$sql = "SELECT `id` as `uid` , `name` , `timeline` , `level`, `cover` , `picture` FROM `user` WHERE `id` = '" . intval( $_SESSION['uid'] ) . "' LIMIT 1"; $user = get_user_info_by_id($_SESSION['username']); if ($user) { //$user['refresh_time'] = date("m月d日 H:i"); $this->send_result($user); } else { return $this->send_error(OP_API_USER_ERROR, 'NO SUCH UID'); } }