Example #1
0
 public function leave()
 {
     $smarty = parent::load('smarty');
     $leave_form = parent::load('form', 'LeaveForm', $_POST);
     parent::load('model', 'forms');
     parent::load('model', 'system/contrib/auth.User');
     if (!$this->is_post()) {
         import('system/share/web/paginator');
         if (User::has_role('人力资源') || User::has_role('总经理')) {
             $data = Forms::get_by_type_and_user('请假申请');
             $smarty->assign('has_role', true);
         } else {
             $data = Forms::get_by_type_and_user('请假申请', User::info('id'));
         }
         $paginator = new Paginator((array) $data, $_GET['page'], 10);
         $smarty->assign('paginator', $paginator->output());
         $smarty->assign('page_title', '请假申请');
         $smarty->assign('leave_form', $leave_form->output());
         $smarty->display('forms/leave');
         return;
     }
     $form_data = new Forms();
     $form_data->user_id = User::info('id');
     $form_data->state = 0;
     $form_data->type = '请假申请';
     $form_data->form_data = serialize($_POST);
     $form_data->save();
     import('system/share/network/redirect');
     HTTPRedirect::flash_to('forms/leave', '提交请假申请成功, 请耐心等待审核', $smarty);
 }
Example #2
0
 public static function logOut($logout)
 {
     if ($logout) {
         unset($_SESSION[self::$session_name]);
         unset($_SESSION['user_info']);
         unset($_SESSION['token_verified']);
         self::$logged_in = false;
         self::$info = false;
     }
 }
Example #3
0
 public static function setInfo($info)
 {
     User::$info = $info;
     if (!empty($info['id'])) {
         $balances = self::getBalances($info['id']);
         if ($balances) {
             foreach ($balances as $abbr => $row) {
                 User::$info[$abbr] = $row;
             }
         }
     }
 }
Example #4
0
 public function add($order_id)
 {
     AuthPlugins::required($this, array('销售经理', '销售顾问'));
     $order_id = abs(intval($order_id));
     $content = trim(nl2br(strip_tags($_POST['content'])));
     if (!$order_id || !$this->is_post() || !$content) {
         return false;
     }
     parent::load('model', 'Order.Communication');
     $c = new Communication();
     $c->order_id = $order_id;
     $c->content = $content;
     $c->user_id = User::info('id');
     $c->save();
     echo 'ok';
 }
Example #5
0
 public function findUserAction($gps, $long)
 {
     if (count(array_filter($gps)) != 2 || !$long) {
         sendMsg('Data Error', 1);
     }
     $mlist = $this->mdb->command(['geoNear' => 'auths', 'near' => [doubleval($gps[0]), doubleval($gps[1])], 'spherical' => true, 'maxDistance' => $long / 6371000, 'distanceMultiplier' => 6371]);
     if (!$mlist['ok']) {
         sendMsg('Find Error', 1);
     }
     $info['results'] = array();
     $userModel = new User();
     foreach ($mlist['results'] as $val) {
         if ((string) $this->auth->getAuth('userId') != (string) $val['obj']['userId']) {
             $info['results'][] = ['userId' => (string) $val['obj']['userId'], 'user' => $userModel->info($val['obj']['userId']), 'userGame' => $userModel->ginfo($val['obj']['userId']), 'userIm' => $userModel->iminfo($val['obj']['userId']), 'GPS' => $val['obj']['addr'], 'pab' => getPab(doubleval($gps[0]), doubleval($gps[1]), $val['obj']['addr']['lng'], $val['obj']['addr']['lat']), 'ht' => $val['obj']['ht'], 'distance' => ceil($val['dis'] * 1000)];
         }
     }
     sendMsg($info);
 }
Example #6
0
 public function start($type, $order_id)
 {
     AuthPlugins::required($this, $this->available_type_permission[$type]);
     if (!array_key_exists($type, $this->available_type)) {
         $this->unsupported($type);
     }
     $smarty = parent::load('smarty');
     import('system/share/network/redirect');
     parent::load('model', 'system/contrib/auth');
     parent::load('model', 'order');
     parent::load('model', 'work');
     /*
      * 是否此人工作
      */
     $order = Order::get_by_id($order_id);
     $userinfo = User::info();
     if ($order->designer_id != $userinfo['id'] && $order->layouter_id != $userinfo['id'] && $order->programmer != $userinfo['id']) {
         $message = '这份工作好像不属于你';
         HTTPRedirect::flash_to('order', $message, $smarty);
     }
     /*
      * 下一工作流程
      */
     $workflow = Workflow::get_by_alias($this->available_type[$type]);
     $work = OrderWork::get_by_order($order_id, $type);
     /*
      * 工作已经开始
      */
     if ($work) {
         $message = sprintf('此订单的 %s 工作已经开始', $this->available_type[$type]);
         HTTPRedirect::flash_to('order/list/' . $workflow->id, $message, $smarty);
     }
     $work = new OrderWork();
     $work->order_id = $order_id;
     $work->process = '10';
     $work->type = $type;
     $work->user_id = User::info('id');
     $work->save();
     $message = '标记工作开始成功, 工作进度被设为10%, 请及时登记您的工作进度';
     HTTPRedirect::flash_to('order/list/' . $workflow->id, $message, $smarty);
 }
Example #7
0
 public function index()
 {
     $smarty = parent::load('smarty');
     parent::load('model', 'articles');
     $news = Doctrine_Query::create()->select('id, name, created_at')->from('Article a')->orderBy('id DESC')->limit('6')->fetchArray();
     /*
      * 销售顾问或者销售经理, 显示最近已经联系但是未签约的十个订单
      */
     parent::load('model', 'system/contrib/auth.User');
     if (User::has_role('销售顾问') || User::has_role('销售经理')) {
         parent::load('model', 'order');
         $orders = Doctrine_Query::create()->select('o.*, oc.*')->from('Order o')->leftJoin('o.Customer oc')->where('o.seller_id = ?', User::info('id'))->addWhere('o.workflow_id BETWEEN ? AND ?', array(2, 6))->orderBy('o.subscribe_time DESC')->fetchArray();
         $smarty->assign('long_not_orders', $orders);
     }
     /*
      * 判断是否客服
      */
     if (User::has_role('客服')) {
         $smarty->assign('is_customer_service', true);
     }
     $smarty->assign('news', $news);
     $smarty->assign('page_title', '管理中心');
     $smarty->display('center/index');
 }
Example #8
0
     break;
 }
 $current_count = $total <= $max_connect ? $total : $max_connect;
 for ($i = 1; $i <= $current_count; ++$i) {
     $pid = pcntl_fork();
     if ($pid == -1) {
         echo "--------fork child process failed--------\n";
         exit(0);
     }
     if (!$pid) {
         $startTime = microtime();
         $tmp_redis = PRedis::getInstance();
         $tmp_u_id = $tmp_redis->lpop('request_queue');
         if (empty($tmp_redis->zscore('already_get_queue', $tmp_u_id))) {
             saveUserInfo($tmp_u_id);
             $user_info = User::info($tmp_u_id);
             $user_followees_count = $tmp_redis->hget($tmp_u_id, 'followees_count');
             $user_followers_count = $tmp_redis->hget($tmp_u_id, 'followers_count');
             if ($user_info['followees_count'] != $user_followees_count) {
                 updateUserInfo($tmp_u_id);
                 echo "--------start getting {$tmp_u_id}'s " . $user_info['followees_count'] . " followees user list--------\n";
                 $followee_users = getUserList($tmp_u_id, 'followees', $user_info['followees_count'], 1);
                 $tmp_redis->set($tmp_u_id, 'followees_count', count($followee_users));
                 if (!empty($followee_users)) {
                     foreach ($followee_users as $user) {
                         $tmp_redis->lpush('request_queue', $user[3]);
                     }
                 }
                 Log::info('empty followee_users u_id' . $tmp_u_id);
                 echo "--------get " . count($followee_users) . " followees users done--------\n";
             }
Example #9
0
$id = GETPOST('id', 'int');
$object = new User($db);
$object->fetch($id);
// Security check
$socid = 0;
if ($user->societe_id > 0) {
    $socid = $user->societe_id;
}
$feature2 = $socid && $user->rights->user->self->creer ? '' : 'user';
if ($user->id == $id) {
    $feature2 = '';
}
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
// If user is not user that read and no permission to read other users, we stop
if ($object->id != $user->id && !$user->rights->user->user->lire) {
    accessforbidden();
}
/*
 * View
 */
llxHeader();
$object->info($id);
$head = user_prepare_head($object);
$title = $langs->trans("User");
dol_fiche_head($head, 'info', $title, 0, 'user');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
$db->close();
llxFooter();
Example #10
0
 public function delete($id)
 {
     parent::load('model', 'articles');
     parent::load('model', 'system/contrib/auth.User');
     $article = ArticleTable::getInstance()->find($id);
     /*
      * 判断是否有权限修改此类文章
      */
     $has_role = Category::has_role($article->Category->id, User::info());
     if (!$has_role || !User::has_role('人力资源') || !User::has_role('总经理')) {
         $this->smarty->display(403);
         Boot::shutdown();
     }
     if ($article) {
         $article->delete();
         $message = '删除成功';
     } else {
         $message = '文章不存在';
     }
     import('system/share/network/redirect');
     HTTPRedirect::flash_to('', $message, $this->smarty);
 }
Example #11
0
}
$result = restrictedArea($user, 'user', $id, '&user', $feature2);

// If user is not user read and no permission to read other users, we stop
if (($fuser->id != $user->id) && (! $user->rights->user->user->lire))
  accessforbidden();



/*
 * View
 */

llxHeader();

$fuser->info($id);

$head = user_prepare_head($fuser);

$title = $langs->trans("User");
dol_fiche_head($head, 'info', $title, 0, 'user');


print '<table width="100%"><tr><td>';
dol_print_object_info($fuser);
print '</td></tr></table>';

print '</div>';

$db->close();
Example #12
0
 static function logOut($logout)
 {
     if ($logout && $_REQUEST['uniq'] == $_SESSION["logout_uniq"]) {
         API::add('User', 'logOut', array($_SESSION['session_id']));
         API::send();
         $lang = $_SESSION['language'];
         unset($_SESSION);
         session_destroy();
         session_start();
         $_SESSION['language'] = $lang;
         self::$logged_in = false;
         self::$info = false;
     }
 }
Example #13
0
 public static function setInfo($info)
 {
     User::$info = $info;
 }
Example #14
0
 public function decide_inner($order_id)
 {
     AuthPlugins::required($this, array('客户', '技术经理'));
     $smarty = parent::load('smarty');
     import('system/share/network/redirect');
     $order = Order::get_by_id($order_id);
     /*
      * 判断尾款是否已付,如果已付,直接转入售后部门上线
      */
     $last_pay = Payment::get_by_order_and_state($order_id, 2, 'last');
     $workflow = Workflow::get_by_alias('布局任务');
     $userinfo = User::info();
     if (!$order || ($order->Customer->CustomerUser->id != $userinfo['id'] || $userinfo['role']['0']['alias'] == '技术经理')) {
         echo '无效的订单ID或者您不是此订单的所有者';
         exit;
     }
     $order->workflow_id = $workflow->id;
     $order->save();
     $message = '恭喜您, 内页确认成功';
     $flash_to = $userinfo['role']['0']['alias'] == '技术经理' ? 'order/list/' . $workflow->id : 'customer';
     $template = $userinfo['role']['0']['alias'] == '技术经理' ? 'flash_to' : 'cus_flash_to';
     HTTPRedirect::flash_to($flash_to, $message, $smarty, $template);
 }
Example #15
0
$id = GETPOST('id', 'int');
$fuser = new User($db);
$fuser->fetch($id);
// Security check
$socid = 0;
if ($user->societe_id > 0) {
    $socid = $user->societe_id;
}
$feature2 = $socid && $user->rights->user->self->creer ? '' : 'user';
if ($user->id == $_GET["id"]) {
    $feature2 = '';
}
$result = restrictedArea($user, 'user', $_GET["id"], '', $feature2);
// If user is not user read and no permission to read other users, we stop
if ($fuser->id != $user->id && !$user->rights->user->user->lire) {
    accessforbidden();
}
/*
 * View
 */
llxHeader();
$fuser->info($_GET["id"]);
$head = user_prepare_head($fuser);
$title = $langs->trans("User");
dol_fiche_head($head, 'info', $title, 0, 'user');
print '<table width="100%"><tr><td>';
dol_print_object_info($fuser);
print '</td></tr></table>';
print '</div>';
$db->close();
llxFooter('$Date: 2011/07/31 23:19:42 $ - $Revision: 1.19 $');
Example #16
0
 public static function required($base_app, $role_id_or_name, $only_check = false)
 {
     $has_permission = false;
     $base_app->load('model', 'system/contrib/auth.User', false);
     $userinfo = User::info();
     /*
      * Multi check
      */
     if (is_array($role_id_or_name)) {
         foreach ($role_id_or_name as $value) {
             if (abs(intval($value)) > 0) {
                 $field = 'id';
             } else {
                 $field = 'alias';
             }
             $has_permission = self::__required($userinfo['role'], $value, $field);
             if ($has_permission) {
                 return true;
             }
         }
     }
     /*
      * check by id or name
      */
     if (abs(intval($role_id_or_name)) > 0) {
         $field = 'id';
     } else {
         $field = 'alias';
     }
     $has_permission = self::__required($userinfo['role'], $role_id_or_name, $field);
     if ($has_permission) {
         return true;
     }
     if ($only_check) {
         return false;
     } else {
         $base_app->smarty->display(403);
         Boot::shutdown();
     }
 }
Example #17
0
 /**
  * @request_handler
  * @return array
  */
 public function profile($params)
 {
     $files = new Files();
     $params['user_id'] = User::info('id');
     $result = $files->show_all($params);
     $re = '!^(/\\w+/\\w+/user_id/\\d+)(.*)!';
     $result['data']['user_url'] = (empty($_SERVER["HTTPS"]) ? 'http' : 'https') . '://' . $_SERVER["HTTP_HOST"] . preg_replace($re, '$1', $result['data']['base_url']);
     $result['data']['base_url'] = preg_replace($re, '/users/' . __FUNCTION__, $result['data']['base_url']);
     $result['data'] += User::getFormData();
     return $result;
 }
Example #18
0
 public function select_designer($order_id, $type = '', $user_id = null)
 {
     AuthPlugins::required($this, array('技术经理'));
     $userinfo = User::info();
     foreach ($userinfo['role'] as $role) {
         $roles[] = $role['alias'];
     }
     $order = Order::get_by_id($order_id);
     $workflow = Workflow::get_by_alias('首页设计');
     $user_id = abs(intval($user_id));
     /*
      *
      */
     $smarty = parent::load('smarty');
     if ($user_id) {
         $user = User::get_by_id($user_id);
     } else {
         $smarty->assign('page_title', '分配任务');
         /*
          * 这里可能对设计师的列表有一个条件
          */
         $smarty->assign('order', $order);
         $smarty->assign('designer', User::get_by_role_alias('设计师'));
         $smarty->assign('layouter', User::get_by_role_alias('布局师'));
         $smarty->assign('programmer', User::get_by_role_alias('程序员'));
     }
     /*
      * 技术经理指定
      *
      * 选择设计师 则改变当前的工作流程 进行下一步
      */
     if ($user_id && $user) {
         switch ($type) {
             case 'designer':
                 $order->designer_id = $user_id;
                 $order->Workflow = $workflow;
                 break;
             case 'layouter':
                 $order->layouter_id = $user_id;
                 break;
             case 'programmer':
                 $order->programmer = $user_id;
                 break;
         }
         $order->save();
         $message = sprintf('任务已经成功分配给 %s', $user->name);
         HTTPRedirect::flash_to('order/select_designer/' . $order->id, $message, $smarty);
     } else {
         $smarty->display('order/select_designer');
     }
 }
Example #19
0
File: User.php Project: uwitec/mgoa
 public static function has_role($role_alias)
 {
     $info = User::info('role');
     foreach ($info as $role) {
         if ($role['alias'] == $role_alias) {
             return true;
         }
     }
     return false;
 }
Example #20
0
 public function change_password()
 {
     parent::load('model', 'system/contrib/auth.User');
     $user = UserTable::getInstance()->find(User::info('id'));
     import('system/share/network/redirect');
     if ($this->is_post()) {
         list($func, $random, $encryped) = explode('$', $user->password);
         /*
          * 验证原密码
          */
         if ($user->password && $user->password === User::generate_password($_POST['old_password'], $random, $func)) {
             $user->password = User::generate_password($_POST['new_password']);
             $user->save();
             User::logout();
             $message = '修改密码成功, 请重新登录';
             HTTPRedirect::flash_to(url_reverse('auth_login'), $message, $this->smarty);
         } else {
             $message = '原密码不正确, 请重试';
             HTTPRedirect::flash_to('accounts/change_password', $message, $this->smarty);
         }
     }
     $this->smarty->display('auth/change_password');
 }
Example #21
0
 /**
  * @request_handler
  * @return array
  */
 public function put($params)
 {
     $dir = rtrim(Config::getConfig('repository'), '\\/') . DIRECTORY_SEPARATOR;
     $processed_files = array();
     $db = DB::getInstance();
     $user_id = User::info('id') or $user_id = 0;
     $insert_file = $db->prepare("\n\t\t\tINSERT INTO\n\t\t\t\t`file`\n\t\t\t\t(`file_name`, `original_name`, `type`, `size`, `description`, `user_id`)\n\t\t\tVALUES \n\t\t\t\t(:file_name, :original_name, :type, :size, :description, {$user_id})\n\t\t");
     $ip = $db->quote(ip2long($_SERVER['REMOTE_ADDR']));
     $user_agent = $db->quote($_SERVER['HTTP_USER_AGENT']);
     $insert_upload = $db->prepare("\n\t\t\tINSERT INTO\n\t\t\t\t`upload`\n\t\t\t\t(`file_id`, `ip`, `user_agent`)\n\t\t\tVALUES\n\t\t\t\t(:file_id, {$ip}, {$user_agent})\n\t\t");
     $error_message = '';
     foreach ($_FILES['attach']['error'] as $f => $error) {
         if ($error != UPLOAD_ERR_OK) {
             continue;
         }
         $file_name = uniqid();
         if (!file_exists($dir . $file_name) && move_uploaded_file($_FILES["attach"]['tmp_name'][$f], $dir . $file_name)) {
             try {
                 $db->beginTransaction();
                 $insert_file->execute(array('file_name' => $file_name, 'original_name' => $_FILES["attach"]['name'][$f], 'type' => $_FILES["attach"]['type'][$f], 'size' => $_FILES["attach"]['size'][$f], 'description' => $_POST['description']));
                 $insert_upload->execute(array('file_id' => $db->lastInsertId()));
                 $db->commit();
                 $processed_files[] = $_FILES["attach"]['name'][$f];
             } catch (PDOException $e) {
                 $error_message .= $e->getMessage() . "\n";
                 $db->rollBack();
                 unlink($dir . $file_name);
             }
         } else {
             $error_message .= _('Error occurred while file uploading. Please, try again') . "\n";
         }
     }
     $error_message = nl2br(trim($error_message));
     return array('redirect' => 'upload', 'data' => compact('processed_files', 'error_message'));
 }