コード例 #1
0
ファイル: UserIdentity.php プロジェクト: ducdm87/gamelienminh
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     global $mainframe, $user;
     $user = new YiiUser();
     $this->errorCode = $user->login($this->username, $this->password);
     return !$this->errorCode;
 }
コード例 #2
0
 /**
  * @sendmsg
  */
 public function actionSendmsg()
 {
     //查找我关注的【满足条件才能发邮件】
     $uid = Yii::$app->user->getId();
     $follows = Follow::find()->where(['uid' => $uid])->all();
     if (count($follows) <= 0) {
         Yii::$app->session->setFlash('error', '请您先关注朋友后,再来发消息!');
         return $this->redirect(['index/users']);
     }
     $ids = array();
     foreach ($follows as $v) {
         array_push($ids, $v->fid);
     }
     //发送对象
     $uses = YiiUser::findAll($ids);
     $to = array();
     foreach ($uses as $v) {
         $to[$v->id] = $v->nickname;
     }
     $model = new Msg();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->fid = $uid;
         $model->send_time = time();
         if ($model->save()) {
             Yii::$app->session->setFlash('success', '发送成功!');
         } else {
             Yii::$app->session->setFlash('error', '发送失败!');
         }
         //echo "<pre/>";print_r(Yii::$app->request->post());die();
     }
     return $this->render('sendmsg', ['model' => $model, 'to' => $to]);
 }
コード例 #3
0
ファイル: User.php プロジェクト: ducdm87/gamelienminh
 function register($data_user)
 {
     global $mainframe;
     $captcha = Request::getVar('captcha', null);
     $obj_captcha = Yii::app()->getController()->createAction("captcha");
     if ($obj_captcha->validate($captcha, 0) == false) {
         YiiMessage::raseNotice("Please enter verify code");
         return false;
     }
     if ($_POST['password'] == "") {
         YiiMessage::raseNotice("Please enter password");
         return false;
     }
     if ($_POST['phone'] == "") {
         YiiMessage::raseNotice("Please enter your mobile");
         return false;
     }
     if (Request::getVar('agree', null) == null) {
         YiiMessage::raseNotice("You must agree to Our Terms of Service.");
         return false;
     }
     $tbl_user = YiiUser::getInstance();
     if (!$tbl_user->registration($data_user)) {
         return false;
     }
     return true;
 }
コード例 #4
0
ファイル: Group.php プロジェクト: ducdm87/gamelienminh
 function getListEdit($main_item)
 {
     $cid = Request::getVar("cid", 0);
     $lists = array();
     $items = array();
     $obj_user = YiiUser::getInstance();
     $condition = "";
     if ($main_item->id != 0) {
         $condition = "(`lft` <" . $main_item->lft . " OR `lft` > " . $main_item->rgt . ")";
     }
     $results = $obj_user->getGroups($condition, 'id value, name text, level');
     $items = array_merge($items, $results);
     $lists['parentID'] = buildHtml::select($items, $main_item->parentID, "parentID", "", "size=10", "&nbsp;&nbsp;&nbsp;", "-");
     $items = array();
     if ($main_item->id != 0) {
         $condition = "parentID = " . $main_item->parentID;
         $results = $obj_user->getGroups($condition, 'id value, name text, level');
         $items = array_merge($items, $results);
         $lists['ordering'] = buildHtml::select($items, $cid, "ordering", "", "size=5");
     } else {
         $lists['ordering'] = "Ordering this item after save first";
     }
     $items_status = array();
     $items_status[] = array(-1, 'Default', 'danger');
     $items_status[] = array(1, 'Allow', 'success');
     $items_status[] = array(0, 'Deny', 'danger');
     $lists['item_status'] = $items_status;
     $table_ext = YiiTables::getInstance(TBL_EXTENSIONS);
     $lists['ext_default_1'] = $table_ext->loadColumn("name", "allowall = 1 ");
     return $lists;
 }
コード例 #5
0
ファイル: Users.php プロジェクト: ducdm87/gamelienminh
 function getListEdit($main_item)
 {
     $obj_user = YiiUser::getInstance();
     $condition = "`level` >= 1 ";
     $items = $obj_user->getGroups($condition, 'id value, name text, level');
     $list['groupID'] = buildHtml::select($items, $main_item->groupID, "groupID", "", "size=10", "&nbsp;&nbsp;&nbsp;", "-");
     return $list;
 }
コード例 #6
0
ファイル: Video.php プロジェクト: ducdm87/gamelienminh
 function getList()
 {
     global $user;
     $list = array();
     $filter_created_by = Request::getVar('filter_created_by', $user->id);
     $filter_state = Request::getVar('filter_state', -2);
     $obj_user = new YiiUser();
     $all_user[] = array("value" => -2, "text" => "- Select User -");
     //$all_user = array_merge($all_user, $obj_user->getUsers(null, 'id value, username text'));
     $all_user = array_merge($all_user, $obj_user->getUserInGroup($user->groupID, 'id value, username text', true));
     $list['filter_created_by'] = buildHtml::select($all_user, $filter_created_by, "filter_created_by", "filter_created_by", "onchange=\"document.adminForm.submit();\"");
     $items = array();
     $items[] = array("value" => -2, "text" => "- Select state -");
     $items[] = array("value" => 0, "text" => "Unpublish");
     $items[] = array("value" => 1, "text" => "Publish");
     $items[] = array("value" => 2, "text" => "Featured");
     $list['filter_state'] = buildHtml::select($items, $filter_state, "filter_state", "filter_state", "onchange=\"document.adminForm.submit();\"");
     return $list;
 }
コード例 #7
0
 function actionGrant()
 {
     global $mainframe, $user;
     if (!$user->isSuperAdmin()) {
         YiiMessage::raseNotice("Your account not have permission to visit page");
         $this->redirect(Router::buildLink("cpanel"));
     }
     global $user;
     $cid = Request::getVar('cid', 0);
     $obj_user = YiiUser::getInstance();
     $obj_user = $obj_user->getUser($cid);
     $this->addBarTitle("Grant user <small>[{$obj_user->username}]</small>", "user");
     $this->addIconToolbar("Save", Router::buildLink("permission", array('view' => 'users', 'layout' => 'save')), "save");
     $this->addIconToolbar("Apply", Router::buildLink("permission", array('view' => 'users', 'layout' => 'apply')), "apply");
     $this->addIconToolbar("Close", Router::buildLink("permission", array('view' => 'users', 'layout' => 'cancel')), "cancel");
     $this->pageTitle = "Edit grant";
     $model_resource = Resource::getInstance();
     $model = Users::getInstance();
     $items = $model_resource->getItems();
     $all_granted = $model->getGranted();
     $lists = $model->getListGrant();
     $this->render('grant', array("items" => $items, "all_granted" => $all_granted, "lists" => $lists));
 }
コード例 #8
0
ファイル: Groups.php プロジェクト: ducdm87/gamelienminh
 function getList()
 {
     $lists = array();
     $filter_state = Request::getVar('filter_state', -2);
     $filter_search = Request::getVar('filter_search', "");
     $filter_group = Request::getVar('filter_group', 0);
     $items = array();
     $items[] = array("value" => -2, "text" => "- Select state -");
     $items[] = array("value" => 0, "text" => "Unpublish");
     $items[] = array("value" => 1, "text" => "Publish");
     $items[] = array("value" => -1, "text" => "Block");
     $lists['filter_state'] = buildHtml::select($items, $filter_state, "filter_state", "filter_state", "onchange=\"document.adminForm.submit();\"");
     global $user;
     $obj_user = YiiUser::getInstance();
     $group = $obj_user->getGroup($user->groupID);
     $condition = "parentID > 0";
     if ($group->parentID != 1) {
         $condition = "`lft` >= {$group->lft} AND `rgt` <= {$group->rgt} ";
     }
     $groups = $obj_user->getGroups($condition, 'id value, name text, level');
     array_unshift($groups, array("value" => 0, 'text' => '-- Select group --'));
     $lists['filter_group'] = buildHtml::select($groups, $filter_group, "filter_group", "", "onchange=\"document.adminForm.submit();\"", "&nbsp;&nbsp;&nbsp;", "");
     return $lists;
 }
コード例 #9
0
 function actionRemove()
 {
     global $user;
     $cids = Request::getVar("cid", 0);
     $obj_table = YiiTables::getInstance(TBL_VIDEOS);
     if (count($cids) > 0) {
         for ($i = 0; $i < count($cids); $i++) {
             $cid = $cids[$i];
             $obj_table->load($cid);
             if (!($bool = $user->modifyChecking($obj_table->created_by))) {
                 $obj_users = YiiUser::getInstance();
                 $item_user = $obj_users->getUser($obj_table->created_by);
                 YiiMessage::raseNotice("Your account not have permission to delete video: {$obj_table->title}");
                 $this->redirect(Router::buildLink("videos"));
                 return false;
             }
             //check item first
             $obj_table->remove($cid);
         }
     }
     YiiMessage::raseSuccess("Successfully remove Video(s)");
     $this->redirect(Router::buildLink("videos"));
 }
コード例 #10
0
ファイル: Users.php プロジェクト: ducdm87/gamelienminh
 function getListEdit($main_item)
 {
     global $user;
     $modelGroup = new Group();
     $obj_user = YiiUser::getInstance();
     $group = $modelGroup->getItem($user->groupID);
     $condition = "";
     if ($group->parentID != 1) {
         $condition = "`lft` >= {$group->lft} AND `rgt` <= {$group->rgt} ";
     }
     $items = $obj_user->getGroups($condition, 'id value, name text, level');
     $lists['groupID'] = buildHtml::select($items, $main_item->groupID, "groupID", "", "size=10", "&nbsp;&nbsp;&nbsp;", "-");
     $items = array();
     $items[] = array("value" => -2, "text" => "- Select status -");
     $items[] = array("value" => 0, "text" => "Unpublish");
     $items[] = array("value" => 1, "text" => "Publish");
     $items[] = array("value" => -1, "text" => "Block");
     $lists['status'] = buildHtml::select($items, $main_item->status, "status", "status");
     $items_status = array();
     $items_status[] = array(-1, 'Default', 'danger');
     $items_status[] = array(1, 'Allow', 'success');
     $items_status[] = array(0, 'Deny', 'danger');
     $lists['item_status'] = $items_status;
     $table_ext = YiiTables::getInstance(TBL_EXTENSIONS);
     $lists['ext_default_1'] = $table_ext->loadColumn("name", "allowall = 1 ");
     return $lists;
 }
コード例 #11
0
 function actionRemove()
 {
     global $user;
     $model = new Group();
     $mode_user = new Users();
     if (!$user->isSuperAdmin()) {
         YiiMessage::raseNotice("Your account not have permission to add/edit group");
         $this->redirect(Router::buildLink("users", array('view' => 'group')));
     }
     $cids = Request::getVar("cid", 0);
     if (count($cids) > 0) {
         $obj_table = YiiUser::getInstance();
         for ($i = 0; $i < count($cids); $i++) {
             $cid = $cids[$i];
             $list_user = $mode_user->getUsers($cid, null, true);
             $list_group = $model->getItems($cid);
             if (empty($list_user) and empty($list_group)) {
                 $obj_table->removeGroup($cid);
             } else {
                 YiiMessage::raseNotice("Group user have something account/sub group");
                 $this->redirect(Router::buildLink("users", array('view' => 'group')));
                 return false;
             }
         }
     }
     YiiMessage::raseSuccess("Successfully delete GroupUser(s)");
     $this->redirect(Router::buildLink("users", array("view" => "group")));
 }
コード例 #12
0
ファイル: Tournaments.php プロジェクト: ducdm87/gamelienminh
 function getListEdit($main_item)
 {
     $cid = Request::getVar("cid", 0);
     $lists = array();
     $items = array();
     $obj_tblTournament = YiiTables::getInstance(TBL_GS_TOURNAMEMANTS);
     $obj_user = YiiUser::getInstance();
     $condition = "";
     if ($main_item->id != 0) {
         $condition = "(`lft` <" . $main_item->lft . " OR `lft` > " . $main_item->rgt . ")";
     }
     $results = $obj_tblTournament->loads('id value, name text, level', $condition, 'lft ASC', null);
     $items = array_merge($items, $results);
     $lists['parentID'] = buildHtml::select($items, $main_item->parentID, "parentID", "", "size=10", "&nbsp;&nbsp;&nbsp;", "-");
     $items = array();
     if ($main_item->id != 0) {
         $condition = "parentID = " . $main_item->parentID;
         $results = $obj_tblTournament->loads('id value, name text, level', $condition, 'lft ASC', null);
         $items = array_merge($items, $results);
         $lists['ordering'] = buildHtml::select($items, $cid, "ordering", "", "size=5");
     } else {
         $lists['ordering'] = "Ordering this item after save first";
     }
     return $lists;
 }
コード例 #13
0
 function changeFeature($cid, $value)
 {
     $obj_table = YiiArticle::getInstance();
     $obj_table = $obj_table->loadItem($cid);
     // check quyen so huu
     global $user;
     if (!($bool = $user->modifyChecking($obj_table->created_by))) {
         $obj_users = YiiUser::getInstance();
         $item_user = $obj_users->getUser($obj_table->created_by);
         YiiMessage::raseNotice("Your account not have permission to modify resource of: {$item_user->username}");
         $this->redirect(Router::buildLink("articles"));
         return false;
     }
     $obj_table->feature = $value;
     $obj_table->store();
 }
コード例 #14
0
ファイル: Article.php プロジェクト: ducdm87/gamelienminh
 public function storeItem()
 {
     global $mainframe, $user;
     $cid = Request::getVar("id", 0);
     $obj_table = YiiArticle::getInstance();
     $obj_table = $obj_table->loadItem($cid);
     $obj_table->bind($_POST);
     if ($obj_table->id == 0) {
         $obj_table->created_by = $user->id;
     } else {
         // check quyen so huu
         global $user;
         if (!($bool = $user->modifyChecking($obj_table->created_by))) {
             $obj_users = YiiUser::getInstance();
             $item_user = $obj_users->getUser($obj_table->created_by);
             YiiMessage::raseNotice("Your account not have permission to modify resource of: {$item_user->username}");
             $this->redirect(Router::buildLink("articles"));
             return false;
         }
     }
     $obj_table->modified_by = $user->id;
     $obj_table->store();
     YiiMessage::raseSuccess("Successfully save Article");
     return $obj_table->id;
 }
コード例 #15
0
 function actionRemove()
 {
     global $user;
     $cids = Request::getVar("cid", 0);
     if (count($cids) > 0) {
         $obj_users = YiiUser::getInstance();
         for ($i = 0; $i < count($cids); $i++) {
             $cid = $cids[$i];
             $item_user = $obj_users->getUser($cid);
             if (!$user->isSuperAdmin()) {
                 // neu khong phai super admin
                 if ($item_user->status != -1) {
                     // neu != -1 thi khong duoc xoa
                     YiiMessage::raseNotice("Please contact your administrator,\"{$item_user->username}\" is active");
                     $this->redirect(Router::buildLink("users", array('view' => 'user')));
                     return false;
                 } elseif (!($bool = $user->modifyChecking($cid))) {
                     // neu =-1 thi user leader nhom cha duoc xoa user con
                     YiiMessage::raseNotice("Your account not have permission to remove user: {$item_user->username}");
                     $this->redirect(Router::buildLink("users", array('view' => 'user')));
                     return false;
                 }
             }
             $obj_users->removeUser($cid);
         }
     }
     YiiMessage::raseSuccess("Successfully delete User(s)");
     $this->redirect(Router::buildLink("users", array("view" => "user")));
 }