/**
  * Снимаем онлайн у тех, у кого за последнее время активность == 0
  */
 public function actionRefreshOnline()
 {
     $oldTime = time() - \Yii::$app->params['onlineLength'];
     $userUpdated = User::updateAll(['<=', 'updated', $oldTime]);
     $this->stdout(Console::wrapText("- {$userUpdated} отправлено в оффлайн", 10), Console::BOLD);
     $this->stdout("\n");
 }
 public function import()
 {
     $newList = [];
     $ldap = new LdapComponent();
     $members = $ldap->groupSearch('cubric-int');
     $email = '';
     User::updateAll(['status_id' => Types::$status['inactive']['id']], 'status_id=' . Types::$status['active']['id']);
     foreach ($members as $dn) {
         $user_name = $this->_parseUserDn($dn);
         $userModel = User::findOne(['user_name' => $user_name]);
         $rec = $ldap->search(sprintf('uid=%s', $user_name));
         $rec = $rec['data'][0];
         if ($userModel === null) {
             if (array_key_exists('email', $rec)) {
                 $email = $rec['mail'][0];
             } else {
                 $email = sprintf('*****@*****.**', $user_name);
             }
             $userModel = new User();
             $userModel->user_name = $user_name;
             $userModel->email = $email;
             $newList[] = ['user_name' => $user_name, 'first_name' => $rec['givenname'][0], 'last_name' => $rec['sn'][0], 'email' => $email];
         }
         //if (array_key_exists('telephonenumber', $rec))
         //    echo ($rec['telephonenumber'][0]) . "<br/>";
         $userModel->first_name = $rec['givenname'][0];
         $userModel->last_name = $rec['sn'][0];
         $userModel->gid = $rec['gidnumber'][0];
         $userModel->uid = $rec['uidnumber'][0];
         $userModel->dn = $dn;
         $userModel->status_id = Types::$status['active']['id'];
         $userModel->save();
     }
     foreach ($newList as $u) {
         yii::$app->LogComponent->activateUser($u['user_name'], sprintf('Adding user: %s %s', $u['first_name'], $u['last_name']));
         if (array_key_exists('email', $u)) {
             yii::$app->LogComponent->emailSend($u['user_name'], sprintf('Welcome email sent to %s', $u['email']));
             $this->sendWelcomeEmail($u['user_name'], $u['email']);
         }
     }
     return $newList;
 }
Example #3
0
 public function actionChangestatus()
 {
     $data = json_decode(file_get_contents("php://input"));
     $query = User::updateAll(['status' => $data->status], 'sn = ' . $data->id);
     if ($query) {
         $response["status"] = 'success';
         $response["message"] = 'Status changed successfully.';
         //$response["data"]=(int)$model->id;
         http_response_code(200);
         header('Content-type: application/json');
         echo json_encode($response, JSON_NUMERIC_CHECK);
     }
 }
Example #4
0
 /**
  * 清除通知数
  * @return mixed
  */
 public static function clearNotifyCount()
 {
     return User::updateAll(['notification_count' => '0'], ['id' => \Yii::$app->user->id]);
 }
Example #5
0
 public function actionLockUsers($ids)
 {
     if (!Yii::$app->user->can("admin")) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     $this->layout = "admin";
     User::updateAll(['status' => User::STATUS_LOCK], "id in (" . $ids . ") ");
     $this->redirect('referrer');
 }
Example #6
0
 public static function toBigPicArctileShow($object, User $weixinuser, Activity $activity, Activity $re_activity)
 {
     $strPicurl = "https://mmbiz.qlogo.cn/mmbiz/3Nsx3YNMeOv6rg4at4Txeak4b9Wkiaq9ibIw7z3V0jFgoXRnCoAfs06y6VRYdzbsSicMRia4nIAyDzkzcjMxzdA3aw/0?wx_fmt=jpeg";
     $strUrl = "http://mp.weixin.qq.com/s?__biz=MzAwNDU3NjAwMw==&mid=402239047&idx=1&sn=96477c6d8807242d4bd75ecf021fbde0#rd";
     $result = $activity->toRollActivity($weixinuser, $activity->id);
     #增加提醒记录
     $activityRemind = new ActivityRemind();
     $activityRemind->setAttributes(['activity_id' => $re_activity->id, 'user_id' => $weixinuser->user_id, 'remind_name' => $re_activity->ac_name, 'remind_mark' => $re_activity->ac_cname, 'remind_type' => 0, 'addtime' => time()]);
     $activityRemind->save();
     if ($result['status'] != 2) {
         User::updateAll(['purview' => time()], 'user_id=:user_id', [':user_id' => $weixinuser->user_id]);
     }
     if ($result['status'] == 1) {
         $strPicurl = "https://mmbiz.qlogo.cn/mmbiz/3Nsx3YNMeOv6rg4at4Txeak4b9Wkiaq9ibIw7z3V0jFgoXRnCoAfs06y6VRYdzbsSicMRia4nIAyDzkzcjMxzdA3aw/0?wx_fmt=jpeg";
         $strUrl = "http://mp.weixin.qq.com/s?__biz=MzAwNDU3NjAwMw==&mid=402239047&idx=1&sn=96477c6d8807242d4bd75ecf021fbde0#rd";
     }
     $strTitle = $result['remark'];
     $strDes = $result['remark'];
     $content = [0 => ['title' => $strTitle, 'des' => $strDes, 'picurl' => $strPicurl, 'url' => $strUrl], 1 => ['title' => '春节初一至初十五天天抽奖。抽完为止。', 'des' => 'ooo', 'picurl' => 'https://mmbiz.qlogo.cn/mmbiz/3Nsx3YNMeOv6rg4at4Txeak4b9Wkiaq9ib9tjFrJOGZQmfeAC4WapMdKMA7ZkfBLjicel4rwxdicOxhCHN3Z1y1rTQ/0?wx_fmt=jpeg', 'url' => 'http://mp.weixin.qq.com/s?__biz=MzAwNDU3NjAwMw==&mid=402303743&idx=1&sn=e9f6232ec4b8cf5e0b6faa8f89b28cbe#rd'], 2 => ['title' => '免费获取各种商品打折券,春节就要省省省。', 'des' => 'xxx', 'picurl' => 'https://mmbiz.qlogo.cn/mmbiz/3Nsx3YNMeOv6rg4at4Txeak4b9Wkiaq9ibuiamOrlB3usT9VuzibYFdAn0EFAANbic6C94U969Iy9oIqIUJa80N15cg/0?wx_fmt=jpeg', 'url' => 'http://mp.weixin.qq.com/s?__biz=MzAwNDU3NjAwMw==&mid=402303933&idx=1&sn=9f1b157a47d14c2dee8da2c14fc6abb4#rd']];
     WechatCheck::_transmitArticleAndPic($object, $content);
 }
Example #7
0
 public function actionUnblock_user($id)
 {
     if (User::isAdmin(Yii::$app->user->identity->username)) {
         if (User::updateAll(['status' => User::STATUS_ACTIVE], ['id' => $id])) {
             return $this->redirect('/user/view');
         } else {
             throw new ForbiddenHttpException('Ошибка разблокирования пользователя', 404);
         }
     } else {
         throw new ForbiddenHttpException('У вас нет прав администратора!', 404);
     }
 }
Example #8
0
 public function actionChangeThemeColor($id)
 {
     User::updateAll(['themeId' => $id], 'id=' . Yii::$app->user->getId());
     $this->redirect('?r=site/index');
 }