Example #1
0
 function on_submit()
 {
     $user_name = AZLib::getParam('user_name');
     $content = AZLib::getParam('content');
     $active = (int) Url::get('active');
     $expire = (int) Url::get('expire', 7);
     $id = (int) Url::get('id');
     $cmd = Url::get('cmd');
     $sql = "SELECT id FROM user WHERE user_name='{$user_name}'";
     $row = DB::fetch($sql);
     $user_id = (int) $row["id"];
     if (!$user_id) {
         $this->setFormError('user_name', 'Không tồn tại thành viên này!');
     } elseif (!$user_name || !$content) {
         $this->setFormError('content', 'Dữ liệu không hợp lệ!');
     } else {
         if ($cmd == "add") {
             $item_array = array('content' => $content, 'user_name' => $user_name, 'user_id' => $user_id, 'admin_add' => User::user_name(), 'active' => $active, 'time_add' => TIME_NOW, 'expire_date' => TIME_NOW + 86400 * $expire);
             DB::insert('admin_notice_user', $item_array);
         } elseif ($cmd == "edit" && $id) {
             $item_array = array('content' => $content, 'user_name' => $user_name, 'user_id' => $user_id, 'admin_edit' => User::user_name(), 'active' => $active, 'time_edit' => TIME_NOW, 'expire_date' => TIME_NOW + 86400 * $expire);
             DB::update_id('admin_notice_user', $item_array, $id);
         }
         User::getAdminNoticeUser($user_id, 0, 1);
         Url::redirect_current(array('act'));
     }
 }
Example #2
0
 function delNoticeUser($id)
 {
     if ($id) {
         $re = DB::query("SELECT user_id FROM admin_notice_user WHERE id IN({$id}) ORDER BY id DESC LIMIT 1");
         $user_ids = "";
         while ($row = mysql_fetch_assoc($re)) {
             $user_ids .= ($user_ids ? "," : "") . $row["user_id"];
         }
         if ($user_ids) {
             $arr_ids = explode(",", $user_ids);
             foreach ($arr_ids as $user_id) {
                 User::getAdminNoticeUser($user_id, 0, 1);
             }
         }
         return DB::query("DELETE FROM admin_notice_user WHERE id IN({$id})");
     }
 }
Example #3
0
 function draw()
 {
     global $display;
     $items = array();
     $total = 0;
     if ($this->user && isset($this->user['id'])) {
         $sql = 'SELECT id, time, time_expire, user_name,type,note,admin_name,unlock_user,unlock_time FROM user_lock WHERE user_id=' . $this->user['id'] . ' ORDER BY time  DESC';
         $result = DB::query($sql);
         if ($result) {
             while ($row = mysql_fetch_assoc($result)) {
                 $total++;
                 $row['time'] = date('d/m/y H:i', $row['time']);
                 if ($row['unlock_time']) {
                     $row['unlock_time'] = date('d/m/y H:i', $row['unlock_time']);
                 }
                 if ($row['time_expire']) {
                     $row['time_expire'] = date('d/m/y H:i', $row['time_expire']);
                 } else {
                     $row['time_expire'] = '';
                 }
                 $items[$row['id']] = $row;
             }
         }
         // Canh bao User
         $admin_notice = User::getAdminNoticeUser($this->user['id']);
         $i = 0;
         foreach ($admin_notice as $value) {
             $admin_notice[$i]['time_add'] = date('d/m/Y H:i', $value['time_add']);
             $admin_notice[$i]['expire_date'] = date('d/m/Y H:i', $value['expire_date']);
             $i++;
         }
         $display->add('admin_notice', $admin_notice);
         // End Canh bao User
     }
     $display->add('total', $total);
     $display->add('user', $this->user);
     $display->add('items', $items);
     $display->output('user_log');
 }
Example #4
0
 function admin_notice_user()
 {
     if (!User::have_permit(ADMIN_NOTICE_USER)) {
         echo "no_perm";
         exit;
     }
     $user_id = (int) Url::get('user_id', 0);
     $expire = (int) Url::get('expire', 0);
     $expire = $expire ? $expire : 7;
     $content = EClassApi::getParam('content', "");
     $user = User::getUser($user_id);
     if ($user["id"]) {
         $item_array = array('content' => $content, 'user_name' => $user["user_name"], 'user_id' => $user_id, 'admin_add' => User::user_name(), 'time_add' => TIME_NOW, 'expire_date' => TIME_NOW + 86400 * $expire);
         DB::insert('admin_notice_user', $item_array);
         User::getAdminNoticeUser($user_id, 0, 1);
     } else {
         echo "fail";
         exit;
     }
 }