Example #1
0
 function getTotal($cid = null)
 {
     $cond = $this->buildWhere($cid);
     $obj_tblTournament = YiiTables::getInstance(TBL_CATEGORIES);
     $total = $obj_tblTournament->getTotal($cond);
     return $total;
 }
Example #2
0
 public function getExtensionById($id)
 {
     global $mainframe;
     $obj_row = YiiTables::getInstance(TBL_EXTENSIONS);
     $obj_row->load($id);
     $path = Yii::app()->basePath . '/extensions/modules/' . $obj_row->folder;
     $module_xml_file = $path . "/" . $obj_row->folder . ".xml";
     if (!file_exists($module_xml_file)) {
         YiiMessage::raseWarning("Error! file xml module is not existing!.");
         $mainframe->redirect(Yii::app()->createUrl("/modules"));
     }
     $params = sysLoadXmlParam($module_xml_file, $obj_row->params);
     $obj_row->params = $params;
     return $obj_row;
 }
Example #3
0
 function loadModule($moduleID = null, $field = null)
 {
     if ($moduleID === 0 || $moduleID == "") {
         return YiiTables::getInstance(TBL_MODULES);
     }
     if ($field == null) {
         $field = "a.id, a.title, a.alias, a.cdate, a.mdate, a.ordering, a.position, a.module, a.description, a.status + 2*(b.status - 1) as status, a.params";
     }
     $command = $this->_db->createCommand()->select($field)->from(TBL_MODULES . " as a")->rightjoin(TBL_EXTENSIONS . " as b", " ON a.module = b.folder");
     if ($conditions != null) {
         $command->where("a.id = {$moduleID}");
     }
     $items = $command->queryRow();
     return $items;
 }
Example #4
0
 function getCategory($catID, $alias = null)
 {
     $obj_table = YiiTables::getInstance(TBL_CATEGORIES);
     $obj_video = YiiTables::getInstance(TBL_VIDEOS);
     if (intval($catID) > 0) {
         $item = $obj_table->loadRow("*", " status = 1 AND `id` = {$catID}");
     } else {
         $item = $obj_table->loadRow("*", " status = 1 AND `alias` = '{$alias}'");
     }
     if ($item) {
         $params = array("view" => "category", "id" => $item['id'], "alias" => $item['alias']);
         $item['link'] = Router::buildLink('videos', $params);
         $item['total'] = $obj_video->getTotal(" status = 1 AND `catID` = " . $item['id']);
     }
     return $item;
 }
 public function store()
 {
     global $mainframe, $user;
     $cid = Request::getVar("id", 0);
     $obj_table = YiiTables::getInstance(TBL_RSM_RESOURCES);
     $obj_table = $obj_table->load($cid);
     $obj_table->bind($_POST);
     if ($obj_table->id == 0) {
         $obj_table->created_by = $user->id;
     }
     $obj_table->modified_by = $user->id;
     $obj_table->app = $_POST['params_app'];
     $obj_table->store();
     YiiMessage::raseSuccess("Successfully save Permission");
     return $obj_table->id;
 }
Example #6
0
 function actionCheckMobile()
 {
     global $user;
     $mobile = Request::getVar('mobile', '');
     $obj_return = new stdClass();
     $obj_return->valid = false;
     if ($mobile == "") {
         $obj_return->valid = false;
     } else {
         $tbl_user = YiiTables::getInstance(TBL_USERS);
         $cond = "mobile = '" . $mobile . "'";
         $bool = $tbl_user->getTotal($cond);
         if ($bool == false or $bool == 0) {
             $obj_return->valid = true;
         }
     }
     echo json_encode($obj_return);
     die;
 }
Example #7
0
 function build($prefix_name = "params", $arr_size = array(5, 7))
 {
     $table_menu = YiiTables::getInstance(TBL_MENU);
     $this->value = (string) $this->value;
     $items = $table_menu->loads("id, title");
     $name = $prefix_name . "[" . $this->node['name'] . "]";
     $id = $prefix_name . "-" . $this->node['name'] . "-";
     $html = '<div class="form-group row"> ' . '<div class="col-md-' . $arr_size[0] . '" title="' . $this->node['description'] . '">' . $this->node['label'] . '</div> ' . '<div class="col-md-' . $arr_size[1] . '"> ';
     $html .= '<select name="' . $name . '" id="' . $id . '" ' . $this->node['attr'] . '>';
     foreach ($items as $item) {
         if ($this->value == $item['id']) {
             $html .= '<option value="' . $item['id'] . '" selected="">' . $item['title'] . '</option> ';
         } else {
             $html .= '<option value="' . $item['id'] . '">' . $item['title'] . '</option> ';
         }
     }
     $html .= "</select>";
     $html .= '</div> ' . " </div>";
     return $html;
 }
Example #8
0
 function getListEdit($mainItem)
 {
     $moduleID = Request::getInt('cid', "");
     $lists = array();
     $obj_menu = YiiMenu::getInstance();
     $obj_module = YiiModule::getInstance();
     $items = $obj_menu->loadMenus();
     $items_xref = $obj_module->loadXrefMenu($moduleID);
     $attr = "";
     $meu_seletec = "selected";
     if ($mainItem->menu == "none") {
         $attr = 'disabled="disabled"';
     } else {
         if ($mainItem->menu == "all") {
             $attr = 'disabled="disabled"';
         }
     }
     $str_html = '<select id="selection-menu" class="inputbox" multiple="multiple" ' . $attr . ' size="15" name="selection-menu[]" style="min-width: 180px;">';
     foreach ($items as $item) {
         $str_html .= '<optgroup label="' . $item['title'] . '">';
         $_items = $item["_items"];
         foreach ($_items as $_item) {
             $str = str_repeat("&nbsp; &nbsp; ", $_item['level'] - 1);
             if ($mainItem->menu == "all") {
                 $str_html .= '<option value="' . $_item['id'] . '" selected ="">' . $str . $_item['title'] . '</option>';
             } else {
                 if ($mainItem->menu == "none") {
                     $str_html .= '<option value="' . $_item['id'] . '">' . $str . $_item['title'] . '</option>';
                 } else {
                     if (in_array($_item['id'], $items_xref)) {
                         $str_html .= '<option value="' . $_item['id'] . '" selected ="">' . $str . $_item['title'] . '</option>';
                     } else {
                         $str_html .= '<option value="' . $_item['id'] . '">' . $str . $_item['title'] . '</option>';
                     }
                 }
             }
         }
         $str_html .= '</optgroup>';
     }
     $str_html .= "</select>";
     $lists['selection-menu'] = $str_html;
     //                position
     $tbl_MP = YiiTables::getInstance(TBL_MODULE_POSITION);
     $items = $tbl_MP->loads("temp, position", null, " temp DESC");
     $str_html = '<div style="position: relative;">';
     $str_html .= '<select id="combobox-position" class="form-control" style="width: 180px; height: 25px;">' . "\r\n";
     $cur_temp = "";
     foreach ($items as $k => $item) {
         if ($cur_temp != $item['temp']) {
             if ($cur_temp != "") {
                 $str_html .= '</optgroup>' . "\r\n";
             }
             $str_html .= '<optgroup label="' . $item['temp'] . '">' . "\r\n";
             $cur_temp = $item['temp'];
         }
         if ($mainItem->position == $item['position']) {
             $str_html .= '<option value="' . $item['position'] . '" selected ="">' . $item['position'] . '</option>' . "\r\n";
         } else {
             $str_html .= '<option value="' . $item['position'] . '">' . $item['position'] . '</option>' . "\r\n";
         }
         if ($k == count($items) - 1) {
             $str_html .= '</optgroup>' . "\r\n";
         }
     }
     $str_html .= "</select>";
     $str_html .= '<input id="position" class="form-control" type="text" value="' . $mainItem->position . '" name="position" style="position: absolute; z-index: 1000; left: 0px; top: 0px; width: 162px; height: 25px; padding: 3px;">' . "\r\n";
     $str_html .= '</div>';
     $str_html .= '<script> $(window).ready(function($) {
                             $("#combobox-position").change(function(){
                                 var cur_pos = $("#combobox-position").val();
                                 $("#position").val(cur_pos);
                             });
                         });</script>';
     $lists['position'] = $str_html;
     $items = array();
     $items[] = array("value" => 0, "text" => "Unpublish");
     $items[] = array("value" => 1, "text" => "Publish");
     $items[] = array("value" => -1, "text" => "Hidden");
     $lists['status'] = buildHtml::select($items, $mainItem->status, "status");
     return $lists;
 }
Example #9
0
 function getGranted()
 {
     $cid = Request::getVar('cid', 0);
     $obj_res_xref = YiiTables::getInstance(TBL_RSM_RESOURCE_XREF);
     $items = $obj_res_xref->loads("*", " object_type = 2 AND objectID = {$cid}");
     if (count($items)) {
         $arr_new = array();
         $arr_new['allow'] = array();
         $arr_new['deny'] = array();
         foreach ($items as $item) {
             if ($item['value'] == 1) {
                 $arr_new['allow'][$item['resourceID']] = $item['resourceID'];
             } else {
                 $arr_new['deny'][$item['resourceID']] = $item['resourceID'];
             }
         }
         $items = $arr_new;
     }
     return $items;
 }
Example #10
0
 public function actionUploadext()
 {
     global $mainframe, $user;
     if (!$user->isSuperAdmin()) {
         YiiMessage::raseNotice("Your account not have permission to install extension");
         $this->redirect(Router::buildLink("cpanel"));
     }
     $pack_install = $_FILES['install_package'];
     if ($pack_install == null or $pack_install['error'] != 0) {
         YiiMessage::raseWarning("Unable to find install package");
         $this->redirect(Router::buildLink("installer"));
     }
     // $YiiFile = new YiiFile;
     $path_file_pach_install = PATH_TMP . $pack_install['name'];
     YiiFile::upload($pack_install['tmp_name'], $path_file_pach_install);
     $file_info = pathinfo($path_file_pach_install);
     if (strtolower($file_info['extension']) != "zip") {
         YiiMessage::raseWarning("Invalid extension install package");
         YiiFile::delete($path_file_pach_install);
         $this->redirect(Router::buildLink("installer"));
     }
     $filename = $file_info['filename'];
     $zip = new ZipArchive();
     $res = $zip->open($path_file_pach_install);
     $path_extact = PATH_TMP . $filename;
     if ($res === TRUE) {
         $zip->extractTo($path_extact);
         $zip->close();
     } else {
         YiiMessage::raseWarning("Invalid extract file install package");
         YiiFile::delete($path_file_pach_install);
         $this->redirect(Router::buildLink("installer"));
     }
     $files_xml = YiiFolder::files($path_extact, "\\.xml", 1, true);
     if (count($files_xml) == 0) {
         YiiFile::delete($path_file_pach_install);
         YiiFolder::delete($path_extact);
         YiiMessage::raseWarning("Invalid extension install package");
         $this->redirect(Router::buildLink("installer"));
     }
     $xml = null;
     foreach ($files_xml as $file_xml) {
         $xml = simplexml_load_file($file_xml);
         if (!$xml) {
             unset($xml);
             continue;
         }
         if ($xml->getName() != 'extension') {
             unset($xml);
             continue;
         }
         $type = (string) $xml->attributes()->type;
         if (!in_array($type, array("app", "module"))) {
             unset($xml);
             continue;
         }
     }
     $type = (string) $xml->attributes()->type;
     $row_ext = YiiTables::getInstance(TBL_EXTENSIONS);
     $arr_info = array();
     $arr_info['title'] = (string) $xml->title;
     $arr_info['name'] = (string) $xml->name;
     $arr_info['alias'] = $this->convertalias($arr_info['title']);
     $arr_info['author'] = (string) $xml->author;
     $arr_info['version'] = (string) $xml->version;
     $arr_info['creationDate'] = (string) $xml->creationDate;
     $arr_info['description'] = (string) $xml->description;
     $arr_info['type'] = (string) $xml->attributes()->type;
     $arr_info['folder'] = trim(preg_replace('/[^\\w\\d]+/is', '', $row_ext->title));
     $arr_info['client'] = (string) $xml->attributes()->client;
     if ($arr_info['client'] == "") {
         $arr_info['client'] = 1;
     }
     $row_ext->loadRow("*", "title = '" . $arr_info['title'] . "' OR alias = '" . $arr_info['alias'] . "'");
     $ext_new = false;
     if ($row_ext->id == 0) {
         $row_ext->cdate = date("Y-m-d H:i:s");
         $ext_new = true;
     }
     $row_ext->mdate = date("Y-m-d H:i:s");
     $row_ext->bind($arr_info);
     $path_ext = PATH_MODULES . $row_ext->folder;
     if ($row_ext->type == "app" and $row_ext->client == 1) {
         $path_ext = PATH_APPS_FRONT . $row_ext->folder;
     } else {
         if ($row_ext->type == "app" and $row_ext->client == 0) {
             $path_ext = PATH_APPS_BACKEND . $row_ext->folder;
         }
     }
     if (!YiiFolder::create($path_ext, 0775)) {
         YiiMessage::raseWarning("FILESYSTEM ERROR Could not create directory");
         YiiFile::delete($path_file_pach_install);
         YiiFolder::delete($path_extact);
         $this->redirect(Router::buildLink("installer"));
     }
     $bool = YiiFolder::copy($path_extact, $path_ext, '', 1);
     if ($row_ext->type == "module" and $ext_new == true) {
         $row_module = YiiTables::getInstance(TBL_MODULES);
         $row_module->title = $row_ext->title;
         $row_module->alias = $row_ext->alias;
         $row_module->cdate = date("Y-m-d H:i:s");
         $row_module->mdate = date("Y-m-d H:i:s");
         $row_module->module = $row_ext->folder;
         $row_module->status = 0;
         $row_module->store();
     }
     YiiFile::delete($path_file_pach_install);
     YiiFolder::delete($path_extact);
     $this->redirect(Router::buildLink("installer"), "Succesfully install package");
 }
Example #11
0
 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;
 }
Example #12
0
 function make_matches($tourID, $matches_data_table)
 {
     global $user;
     $db = Yii::app()->db;
     $obj_team = YiiTables::getInstance(TBL_GS_TEAMS, null, true);
     foreach ($matches_data_table as $matches_intable) {
         if ($matches_intable == null) {
             continue;
         }
         foreach ($matches_intable as $table) {
             if ($table->name == "") {
                 $team_a = $obj_team->load($table->teamaID);
                 $table->teama_name = $team_a->name;
                 $table->teama_alias = $team_a->alias;
                 $team_b = $obj_team->load($table->teambID);
                 $table->teamb_name = $team_b->name;
                 $table->teamb_alias = $team_b->alias;
                 $table->name = "{$table->teama_name} VS {$table->teamb_name}";
                 $table->alias = "{$table->teama_alias}-vs-{$table->teamb_alias}";
             }
             $query = "INSERT INTO " . TBL_GS_MATCHES . " SET id = {$table->id} " . " , `name` = '{$table->name}'" . " ,`alias` = '{$table->alias}'" . " , tourID = '{$table->tourID}'" . " , teamaID = '{$table->teamaID}'" . " , teambID = '{$table->teambID}'" . " , `round` = '{$table->round}'" . " , `group` = '{$table->group}'" . " , subround = '{$table->subround}'" . " , `ordering` = '{$table->ordering}'" . " , `cdate` = now()" . " , `mdate` = now()" . " , `status` = 1" . " , `created_by` = {$user->id}" . " , `modified_by` = {$user->id}" . " ON DUPLICATE KEY UPDATE  `name` = '{$table->name}'" . " , `alias` = '{$table->alias}'" . " , teamaID = '{$table->teamaID}'" . " , teambID = '{$table->teambID}'" . " , ordering = '{$table->ordering}'" . " , `mdate` = now()" . " , `status` = 1" . " , `modified_by` = {$user->id}";
             $command = $db->createCommand($query);
             $command->execute();
         }
     }
 }
 function actionRemove()
 {
     global $mainframe, $user;
     if (!$user->isSuperAdmin()) {
         YiiMessage::raseNotice("Your account not have permission to remove menu item");
         $this->redirect(Router::buildLink("menus", array("view" => 'menutype')));
     }
     $menuID = Request::getInt('menu', "");
     $cids = Request::getVar("cid", 0);
     $table_menu = YiiTables::getInstance(TBL_MENU_ITEM);
     if (count($cids) > 0) {
         for ($i = 0; $i < count($cids); $i++) {
             $cid = $cids[$i];
             //check item first
             $table_menu->remove($cid);
         }
     }
     YiiMessage::raseSuccess("Successfully remove Menuitem(s)");
     $this->redirect(Router::buildLink('menus', array("view" => "menuitem", 'menu' => $menuID)));
 }
Example #14
0
 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;
 }
Example #15
0
 function changeStatus($cid, $value)
 {
     global $user;
     $obj_tblTeam = YiiTables::getInstance(TBL_GS_TEAMS);
     $obj_tblTeam->load($cid);
     $obj_tblTeam->status = $value;
     $obj_tblTeam->store();
 }
 function changeStatus($cid, $value)
 {
     global $user;
     $obj_tblTournament = YiiTables::getInstance(TBL_GS_TOURNAMEMANTS);
     $obj_tblTournament->load($cid);
     $obj_tblTournament->status = $value;
     $obj_tblTournament->store();
 }
Example #17
0
 function changeStatus($cid, $value)
 {
     global $user;
     $obj_tblLocation = YiiTables::getInstance(TBL_LOCATIONS);
     $obj_tblLocation->load($cid);
     $obj_tblLocation->status = $value;
     $obj_tblLocation->store();
 }
Example #18
0
 /**
  * desc: lay 1 menu item
  * $menuItemID:
  */
 function loadItem($menuItemID = null, $field = "*")
 {
     $table_menu_item = YiiTables::getInstance(TBL_MENU_ITEM);
     $table_menu_item->load($menuItemID);
     return $table_menu_item;
 }
 function store()
 {
     global $mainframe, $db, $user;
     $post = $_POST;
     $model = Players::getInstance();
     global $user;
     if (!$user->isSuperAdmin()) {
         YiiMessage::raseNotice("Your account not have permission to add/edit Players");
         $this->redirect(Router::buildLink("gamesport", array('view' => 'players')));
     }
     $id = Request::getVar("id", 0);
     $obj_tblTeam = YiiTables::getInstance(TBL_GS_PLAYERS);
     $obj_tblTeam->load($id);
     $obj_tblTeam->bind($post);
     //        var_dump($obj_tblTeam); die;
     $obj_tblTeam->store();
     return $obj_tblTeam->id;
 }
Example #20
0
 function loadXrefMenu($moduleID)
 {
     $obj_menuitem = YiiTables::getInstance(TBL_MODULE_MENUITEM_REF);
     return $obj_menuitem->loadColumn("menuID", "moduleID = {$moduleID}", null, null);
 }
Example #21
0
 function store()
 {
     global $mainframe, $user;
     $u_id = Request::getInt("id", 0);
     $query = "DELETE FROM " . TBL_RSM_RESOURCE_XREF . " WHERE objectID = {$u_id} AND object_type = 1";
     Yii::app()->db->createCommand($query)->execute();
     if (count($_POST['form'])) {
         foreach ($_POST['form'] as $key => $value) {
             $key = str_replace("resource-", "", $key);
             $obj_table = YiiTables::getInstance(TBL_RSM_RESOURCE_XREF);
             $query = "INSERT INTO " . TBL_RSM_RESOURCE_XREF . " " . "SET objectID = {$u_id}" . ", object_type = 1" . ", resourceID = {$key}" . ", value = {$value}";
             Yii::app()->db->createCommand($query)->execute();
         }
     }
     return $u_id;
 }
Example #22
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"));
 }
Example #23
0
 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;
 }
Example #24
0
 function getListEdit($main_item)
 {
     $cid = Request::getVar("cid", 0);
     $lists = array();
     $db = Yii::app()->db;
     $command = $db->createCommand()->select("A.id, A.name")->from(TBL_GS_TOURNAMEMANTS . " A")->rightJoin(TBL_GS_TEAM_REGISTER_TOUR . ' B', 'A.id = B.tourID')->rightJoin(TBL_GS_TEAMS . ' C', 'C.id = B.teamID')->where(" B.teamID= 1")->group(" A.id")->order('A.startDate DESC');
     $lists['tournaments'] = $command->queryAll();
     $obj_tblLocation = YiiTables::getInstance(TBL_LOCATIONS);
     $locations = $obj_tblLocation->loads("*", 'parentID != 0 ', "lft ASC", null, 0);
     $arr_new = array();
     foreach ($locations as $loc) {
         $arr_new[$loc['id']] = $loc;
     }
     $lists['locations'] = $arr_new;
     return $lists;
 }
Example #25
0
 function changepass()
 {
     global $mainframe;
     $user = $mainframe->getUser();
     $db = $this->db;
     $password = Request::getVar("password");
     $newpassword = Request::getVar("new-password");
     $renewpassword = Request::getVar("renew-password");
     if ($password != "") {
         if (md5($password) != $user->password) {
             YiiMessage::raseNotice('Type old password !!!');
             return FALSE;
         }
     }
     if ($newpassword == "") {
         YiiMessage::raseNotice('Type new password !!!');
         return FALSE;
     }
     if ($newpassword !== $renewpassword) {
         YiiMessage::raseNotice('Type verifi password !!!');
         return FALSE;
     }
     $tbl_user = YiiTables::getInstance(TBL_USERS, null, true);
     $tbl_user->load($user->id);
     $tbl_user->password = md5($newpassword);
     $tbl_user->store();
     return true;
 }
Example #26
0
 function registration($data_post)
 {
     $tbl_user = YiiTables::getInstance(TBL_USERS, null, true);
     $cond = "mobile = '" . $data_post['mobile'] . "'";
     $bool = $tbl_user->getTotal($cond);
     if ($bool) {
         YiiMessage::raseNotice("Your telephone number is already registered");
         return false;
     }
     $cond = " username =  '******'username'] . "'";
     $bool = $tbl_user->getTotal($cond);
     if ($bool) {
         YiiMessage::raseNotice("username is already registered");
         return false;
     }
     $data_post['password'] = md5($data_post['password']);
     $tbl_user->bind($data_post);
     $tbl_user->store();
     $this->setLogin($tbl_user->id);
 }
Example #27
0
 public function getLocations()
 {
     $obj_tblLocation = YiiTables::getInstance(TBL_LOCATIONS);
     $locations = $obj_tblLocation->loads("*", 'parentID != 0 ', "lft ASC", null, 0);
     $arr_new = array();
     foreach ($locations as $loc) {
         $arr_new[$loc['id']] = $loc;
     }
     $locations = $arr_new;
     return $locations;
 }
Example #28
0
 function make_matches($tourID, $matches_data_subround)
 {
     global $user;
     $db = Yii::app()->db;
     $obj_team = YiiTables::getInstance(TBL_GS_TEAMS, null, true);
     $arr_matches_id = array();
     foreach ($matches_data_subround as $num_round => $matches_data_table) {
         if ($matches_data_table == null) {
             continue;
         }
         $arr_matches_id[$num_round] = array();
         foreach ($matches_data_table as $matches_intable) {
             $team_a = $obj_team->load($matches_intable->teamaID);
             $matches_intable->teama_name = $team_a->name;
             $matches_intable->teama_alias = $team_a->alias;
             $team_b = $obj_team->load($matches_intable->teambID);
             $matches_intable->teamb_name = $team_b->name;
             $matches_intable->teamb_alias = $team_b->alias;
             $matches_intable->name = "{$matches_intable->teama_name} VS {$matches_intable->teamb_name}";
             $matches_intable->alias = "{$matches_intable->teama_alias}-vs-{$matches_intable->teamb_alias}";
             $query = "INSERT INTO " . TBL_GS_MATCHES . " SET id = {$matches_intable->id} " . " , `name` = '{$matches_intable->name}'" . " ,`alias` = '{$matches_intable->alias}'" . " , tourID = '{$matches_intable->tourID}'" . " , teamaID = '{$matches_intable->teamaID}'" . " , teambID = '{$matches_intable->teambID}'" . " , `round` = '{$matches_intable->round}'" . " , `group` = '{$matches_intable->group}'" . " , subround = '{$matches_intable->subround}'" . " , `ordering` = '{$matches_intable->ordering}'" . " , `cdate` = now()" . " , `mdate` = now()" . " , `status` = 1" . " , `created_by` = {$user->id}" . " , `modified_by` = {$user->id}" . " ON DUPLICATE KEY UPDATE  `name` = '{$matches_intable->name}'" . " , `alias` = '{$matches_intable->alias}'" . " , teamaID = '{$matches_intable->teamaID}'" . " , teambID = '{$matches_intable->teambID}'" . " , ordering = '{$matches_intable->ordering}'" . " , `mdate` = now()" . " , `status` = 1" . " , `modified_by` = {$user->id}";
             $command = $db->createCommand($query);
             $result = $command->execute();
             $arr_matches_id[$num_round][] = $db->getLastInsertID();
         }
     }
     // tao cac tran dau cua vong tiep theo
     $cur_table = Request::getVar('cur_table', 1);
     $team_intable = $this->getTeams($tourID, $cur_table);
     $tour_detail = $this->getItem($tourID);
     $number_team_pass = $tour_detail->number_teams_de / $tour_detail->number_table;
     $arr_level = array();
     for ($j = 0; $j <= $tour_detail->number_team_table; $j++) {
         $val = $number_team_pass * pow(2, $j);
         if ($val > $tour_detail->number_team_table) {
             break;
         }
         $arr_level[] = $val;
         $max_round = $j;
     }
     $max_level = $arr_level[$max_round];
     $arr_level = array_reverse($arr_level);
     for ($i = $num_round + 1; $i < count($arr_level); $i++) {
         $num_matches = $arr_level[$i];
         $arr_insertedID = $arr_matches_id[$i - 1];
         for ($j = 0; $j < $num_matches; $j++) {
             $teamaID = $arr_insertedID[$j * 2] * -1;
             $teambID = $arr_insertedID[$j * 2 + 1] * -1;
             $subround = $i;
             $query = "INSERT INTO " . TBL_GS_MATCHES . " SET tourID = '{$tourID}'" . " , teamaID = '{$teamaID}'" . " , teambID = '{$teambID}'" . " , `round` = '1'" . " , `group` = '{$cur_table}'" . " , subround = '{$subround}'" . " , `ordering` = {$j}" . " , `cdate` = now()" . " , `mdate` = now()" . " , `status` = 1" . " , `created_by` = {$user->id}" . " , `modified_by` = {$user->id}" . " ON DUPLICATE KEY UPDATE  ordering = {$j}" . " , teamaID = '{$teamaID}'" . " , teambID = '{$teambID}'" . " , `round` = '1'" . " , `group` = '{$cur_table}'" . " , subround = '{$subround}'" . " , `mdate` = now()" . " , `status` = 1" . " , `modified_by` = {$user->id}";
             $command = $db->createCommand($query);
             $result = $command->execute();
             $arr_matches_id[$subround][] = $db->getLastInsertID();
         }
     }
 }
Example #29
0
 function getListEdit($main_item)
 {
     $cid = Request::getVar("cid", 0);
     $menuID = Request::getInt('menu', "");
     $list = array();
     $items[] = array("value" => "-1", "text" => "-- Select Menu --");
     $obj_menu = YiiMenu::getInstance();
     $results = $obj_menu->loadMenus('id value, title text', false);
     $items = array_merge($items, $results);
     $list['menuID'] = buildHtml::select($items, $menuID, "menuID");
     $condition = null;
     if ($main_item->id != 0) {
         $items = array();
         $condition = "parentID = " . $main_item->parentID;
         $results = $obj_menu->loadItems($menuID, 'id value, title text, level', $condition);
         $items = array_merge($items, $results);
         $list['ordering'] = buildHtml::select($items, $cid, "ordering", "", "size=5");
         $condition = "(`lft` <" . $main_item->lft . " OR `lft` > " . $main_item->rgt . ")";
     } else {
         $list['ordering'] = " New Menu Items default to the last position. Ordering can be changed after this Menu Item is saved.";
     }
     $items = array();
     $items[] = array("value" => "1", "text" => "Top", "level" => 0);
     $results = $obj_menu->loadItems($menuID, 'id value, title text, level', $condition);
     $items = array_merge($items, $results);
     $list['parentID'] = buildHtml::select($items, $main_item->parentID, "parentID", "", "size=10", "&nbsp;&nbsp;&nbsp;", "-");
     // danh sach app
     $obj_ext = YiiTables::getInstance(TBL_EXTENSIONS);
     $list['apps'] = $obj_ext->loads("*", "type = 'app'", "ordering ASC");
     foreach ($list['apps'] as $k => $app) {
         if (!is_dir(PATH_APPS_FRONT . "/" . $app['folder'])) {
             unset($list['apps'][$k]);
             continue;
         }
         $file_xml = PATH_APPS_FRONT . "/" . $app['folder'] . "/" . $app['folder'] . ".xml";
         if (!file_exists($file_xml)) {
             YiiMessage::raseSuccess("Invalid xml: " . $app['folder']);
             break;
         }
         $xml = simplexml_load_file($file_xml);
         $views = array();
         foreach ($xml->views->view as $view) {
             $obj_view = new stdClass();
             $obj_view->name = (string) $view->attributes()->name;
             $obj_view->title = (string) $view->attributes()->title;
             $obj_view->desc = (string) $view->attributes()->desc;
             if ($view->layouts) {
                 $obj_view->layouts = array();
                 foreach ($view->layouts->layout as $layout) {
                     $obj_layout = new stdClass();
                     $obj_layout->value = (string) $layout->attributes()->value;
                     $obj_layout->desc = (string) $layout->attributes()->desc;
                     $obj_layout->title = (string) $layout;
                     $obj_view->layouts[] = $obj_layout;
                 }
             }
             $views[] = $obj_view;
         }
         $app['views'] = $views;
         $list['apps'][$k] = $app;
     }
     $app = array();
     $app['name'] = "System";
     $app['title'] = "System Link";
     $app['views'] = array();
     $obj_view = new stdClass();
     $obj_view->name = "ExternalURL";
     $obj_view->title = "External URL";
     $obj_view->desc = "An external or internal URL.";
     $app['views'][] = $obj_view;
     $obj_view = new stdClass();
     $obj_view->name = "MenuItemAlias";
     $obj_view->title = "Menu Item Alias";
     $obj_view->desc = "Create an alias to another menu item.";
     $app['views'][] = $obj_view;
     $obj_view = new stdClass();
     $obj_view->name = "Separator";
     $obj_view->title = "Separator";
     $obj_view->desc = "Separator, Only title";
     $app['views'][] = $obj_view;
     $list['apps'][] = $app;
     return $list;
 }
Example #30
0
 function actionRemove()
 {
     global $mainframe, $user;
     if (!$user->isSuperAdmin()) {
         YiiMessage::raseNotice("Your account not have permission remove category");
         $this->redirect(Router::buildLink("categories"));
     }
     $cids = Request::getVar("cid", 0);
     if (count($cids) > 0) {
         $obj_table = YiiTables::getInstance(TBL_CATEGORIES);
         for ($i = 0; $i < count($cids); $i++) {
             $cid = $cids[$i];
             $obj_table->remove($cid);
         }
     }
     YiiMessage::raseSuccess("Successfully delete GroupUser(s)");
     $this->redirect(Router::buildLink("categories"));
 }