当前位置: 首页>>代码示例>>PHP>>正文


PHP Region::newInstance方法代码示例

本文整理汇总了PHP中Region::newInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::newInstance方法的具体用法?PHP Region::newInstance怎么用?PHP Region::newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Region的用法示例。


在下文中一共展示了Region::newInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRegionbyCountry

 /**
  * List region by country code
  * 
  * @url GET /country/$code/region
  */
 public function getRegionbyCountry($code)
 {
     if ($code) {
         return Region::newInstance()->findByCountry($code);
     }
     return array();
 }
开发者ID:xop32,项目名称:aRestAPI4Osclass,代码行数:12,代码来源:apiServer.php

示例2: ajax

 /**
  * Get the cities having part of the city name and region (it can be null)
  *
  * @access public
  * @since unknown
  * @param string $query The beginning of the city name to look for
  * @param int|null $regionId Region id
  * @return array If there's an error or 0 results, it returns an empty array
  */
 function ajax($query, $regionId = null)
 {
     $this->dao->select('a.pk_i_id as id, a.s_name as label, a.s_name as value, aux.s_name as region');
     $this->dao->from($this->getTableName() . ' as a');
     $this->dao->join(Region::newInstance()->getTableName() . ' as aux', 'aux.pk_i_id = a.fk_i_region_id', 'LEFT');
     $this->dao->like('a.s_name', $query, 'after');
     if ($regionId != null) {
         $this->dao->where('a.fk_i_region_id', $regionId);
     }
     $result = $this->dao->get();
     if ($result == false) {
         return array();
     }
     return $result->result();
 }
开发者ID:jmcclenon,项目名称:Osclass,代码行数:24,代码来源:City.php

示例3: update_location_stats

function update_location_stats()
{
    $aCountries = Country::newInstance()->listAll();
    $aCountryValues = array();
    $aRegions = array();
    $aRegionValues = array();
    $aCities = array();
    $aCityValues = array();
    foreach ($aCountries as $country) {
        $id = $country['pk_c_code'];
        $numItems = CountryStats::newInstance()->calculateNumItems($id);
        array_push($aCountryValues, "('{$id}', {$numItems})");
        unset($numItems);
        $aRegions = Region::newInstance()->findByCountry($id);
        foreach ($aRegions as $region) {
            $id = $region['pk_i_id'];
            $numItems = RegionStats::newInstance()->calculateNumItems($id);
            array_push($aRegionValues, "({$id}, {$numItems})");
            unset($numItems);
            $aCities = City::newInstance()->findByRegion($id);
            foreach ($aCities as $city) {
                $id = $city['pk_i_id'];
                $numItems = CityStats::newInstance()->calculateNumItems($id);
                array_push($aCityValues, "({$id}, {$numItems})");
                unset($numItems);
            }
        }
    }
    // insert Country stats
    $sql_country = 'REPLACE INTO ' . DB_TABLE_PREFIX . 't_country_stats (fk_c_country_code, i_num_items) VALUES ';
    $sql_country .= implode(',', $aCountryValues);
    CountryStats::newInstance()->dao->query($sql_country);
    // insert Region stats
    $sql_region = 'REPLACE INTO ' . DB_TABLE_PREFIX . 't_region_stats (fk_i_region_id, i_num_items) VALUES ';
    $sql_region .= implode(',', $aRegionValues);
    RegionStats::newInstance()->dao->query($sql_region);
    // insert City stats
    $sql_city = 'REPLACE INTO ' . DB_TABLE_PREFIX . 't_city_stats (fk_i_city_id, i_num_items) VALUES ';
    $sql_city .= implode(',', $aCityValues);
    CityStats::newInstance()->dao->query($sql_city);
}
开发者ID:semul,项目名称:Osclass,代码行数:41,代码来源:cron.daily.php

示例4: doModel

 function doModel()
 {
     osc_run_hook('before_search');
     $mCategories = Category::newInstance();
     if (osc_rewrite_enabled()) {
         // IF rewrite is not enabled, skip this part, preg_match is always time&resources consuming task
         $p_sParams = "/" . Params::getParam('sParams', false, false);
         if (preg_match_all('|\\/([^,]+),([^\\/]*)|', $p_sParams, $m)) {
             $l = count($m[0]);
             for ($k = 0; $k < $l; $k++) {
                 switch ($m[1][$k]) {
                     case osc_get_preference('rewrite_search_country'):
                         $m[1][$k] = 'sCountry';
                         break;
                     case osc_get_preference('rewrite_search_region'):
                         $m[1][$k] = 'sRegion';
                         break;
                     case osc_get_preference('rewrite_search_city'):
                         $m[1][$k] = 'sCity';
                         break;
                     case osc_get_preference('rewrite_search_city_area'):
                         $m[1][$k] = 'sCityArea';
                         break;
                     case osc_get_preference('rewrite_search_category'):
                         $m[1][$k] = 'sCategory';
                         break;
                     case osc_get_preference('rewrite_search_user'):
                         $m[1][$k] = 'sUser';
                         break;
                     case osc_get_preference('rewrite_search_pattern'):
                         $m[1][$k] = 'sPattern';
                         break;
                     default:
                         break;
                 }
                 $_REQUEST[$m[1][$k]] = $m[2][$k];
                 $_GET[$m[1][$k]] = $m[2][$k];
                 unset($_REQUEST['sParams']);
                 unset($_GET['sParams']);
                 unset($_POST['sParams']);
             }
         }
     }
     ////////////////////////////////
     //GETTING AND FIXING SENT DATA//
     ////////////////////////////////
     $p_sCategory = Params::getParam('sCategory');
     if (!is_array($p_sCategory)) {
         if ($p_sCategory == '') {
             $p_sCategory = array();
         } else {
             $p_sCategory = explode(",", $p_sCategory);
         }
     }
     $p_sCityArea = Params::getParam('sCityArea');
     if (!is_array($p_sCityArea)) {
         if ($p_sCityArea == '') {
             $p_sCityArea = array();
         } else {
             $p_sCityArea = explode(",", $p_sCityArea);
         }
     }
     $p_sCity = Params::getParam('sCity');
     if (!is_array($p_sCity)) {
         if ($p_sCity == '') {
             $p_sCity = array();
         } else {
             $p_sCity = explode(",", $p_sCity);
         }
     }
     $p_sRegion = Params::getParam('sRegion');
     if (!is_array($p_sRegion)) {
         if ($p_sRegion == '') {
             $p_sRegion = array();
         } else {
             $p_sRegion = explode(",", $p_sRegion);
         }
     }
     $p_sCountry = Params::getParam('sCountry');
     if (!is_array($p_sCountry)) {
         if ($p_sCountry == '') {
             $p_sCountry = array();
         } else {
             $p_sCountry = explode(",", $p_sCountry);
         }
     }
     $p_sUser = Params::getParam('sUser');
     if (!is_array($p_sUser)) {
         if ($p_sUser == '') {
             $p_sUser = '';
         } else {
             $p_sUser = explode(",", $p_sUser);
         }
     }
     $p_sPattern = strip_tags(Params::getParam('sPattern'));
     // ADD TO THE LIST OF LAST SEARCHES
     if (osc_save_latest_searches()) {
         if (trim($p_sPattern) != '') {
             LatestSearches::newInstance()->insert(array('s_search' => trim($p_sPattern), 'd_date' => date('Y-m-d H:i:s')));
         }
//.........这里部分代码省略.........
开发者ID:semul,项目名称:Osclass,代码行数:101,代码来源:search.php

示例5: region_select

 public static function region_select($regions = null, $item = null)
 {
     // if have input text instead of select
     if (Session::newInstance()->_getForm('region') != '') {
         $regions = null;
     } else {
         if ($regions == null) {
             $regions = array();
         }
     }
     if ($item == null) {
         $item = osc_item();
     }
     if (count($regions) >= 1) {
         if (Session::newInstance()->_getForm('regionId') != "") {
             $item['fk_i_region_id'] = Session::newInstance()->_getForm('regionId');
         }
         if (Session::newInstance()->_getForm('countryId') != "") {
             $regions = Region::newInstance()->findByCountry(Session::newInstance()->_getForm('countryId'));
         }
         parent::generic_select('regionId', $regions, 'pk_i_id', 's_name', __('Select a region...'), isset($item['fk_i_region_id']) ? $item['fk_i_region_id'] : null);
         return true;
     } else {
         if (Session::newInstance()->_getForm('region') != "") {
             $item['s_region'] = Session::newInstance()->_getForm('region');
         }
         parent::generic_input_text('region', isset($item['s_region']) ? $item['s_region'] : null);
         return true;
     }
 }
开发者ID:randomecho,项目名称:OSClass,代码行数:30,代码来源:Item.form.class.php

示例6: breadcrumbs

function breadcrumbs($separator = '/')
{
    $text = '';
    $location = Rewrite::newInstance()->get_location();
    $section = Rewrite::newInstance()->get_section();
    $separator = ' ' . trim($separator) . ' ';
    $page_title = '<a href="' . osc_base_url() . '"><span class="bc_root">' . osc_page_title() . '</span></a>';
    switch ($location) {
        case 'item':
            switch ($section) {
                case 'item_add':
                    break;
                default:
                    $aCategories = Category::newInstance()->toRootTree((string) osc_item_category_id());
                    $category = '';
                    if (count($aCategories) == 0) {
                        break;
                    }
                    $deep = 1;
                    foreach ($aCategories as $aCategory) {
                        $list[] = '<a href="' . breadcrumbs_category_url($aCategory['pk_i_id']) . '"><span class="bc_level_' . $deep . '">' . $aCategory['s_name'] . '</span></a>';
                        $deep++;
                    }
                    $category = implode($separator, $list) . $separator;
                    $category = preg_replace('|' . trim($separator) . '\\s*$|', '', $category);
                    break;
            }
            switch ($section) {
                case 'item_add':
                    $text = $page_title . $separator . '<span class="bc_last">' . __('Publish an item', 'breadcrumbs');
                    break;
                case 'item_edit':
                    $text = $page_title . $separator . $category . $separator . '<a href="' . osc_item_url() . '"><span class="bc_item">' . osc_item_title() . '</span></a>' . $separator . '<span class="bc_last">' . __('Edit your item', 'breadcrumbs') . '</span>';
                    break;
                case 'send_friend':
                    $text = $page_title . $separator . $category . $separator . '<a href="' . osc_item_url() . '"><span class="bc_item">' . osc_item_title() . '</span></a>' . $separator . '<span class="bc_last">' . __('Send to a friend', 'breadcrumbs') . '</span>';
                    break;
                case 'contact':
                    $text = $page_title . $separator . $category . $separator . '<a href="' . osc_item_url() . '"><span class="bc_item">' . osc_item_title() . '</span></a>' . $separator . '<span class="bc_last">' . __('Contact seller', 'breadcrumbs') . '</span>';
                    break;
                default:
                    $text = $page_title . $separator . $category . $separator . '<span class="bc_last">' . osc_item_title() . '</span>';
                    break;
            }
            break;
        case 'page':
            $text = $page_title . $separator . '<span class="bc_last">' . osc_static_page_title() . '</span>';
            break;
        case 'search':
            $region = osc_search_region();
            $city = osc_search_city();
            $pattern = osc_search_pattern();
            $category = osc_search_category_id();
            $category = count($category) == 1 ? $category[0] : '';
            $b_show_all = $pattern == '' && $category == '' && $region == '' && $city == '';
            $b_category = $category != '';
            $b_pattern = $pattern != '';
            $b_region = $region != '';
            $b_city = $city != '';
            $b_location = $b_region || $b_city;
            if ($b_show_all) {
                $text = $page_title . $separator . '<span class="bc_last">' . __('Search', 'breadcrumbs') . '</span>';
                break;
            }
            // init
            $result = $page_title . $separator;
            if ($b_category) {
                $list = array();
                $aCategories = Category::newInstance()->toRootTree($category);
                if (count($aCategories) > 0) {
                    $deep = 1;
                    foreach ($aCategories as $single) {
                        $list[] = '<a href="' . breadcrumbs_category_url($single['pk_i_id']) . '"><span class="bc_level_' . $deep . '">' . $single['s_name'] . '</span></a>';
                        $deep++;
                    }
                    // remove last link
                    if (!$b_pattern && !$b_location) {
                        $list[count($list) - 1] = preg_replace('|<a href.*?>(.*?)</a>|', '$01', $list[count($list) - 1]);
                    }
                    $result .= implode($separator, $list) . $separator;
                }
            }
            if ($b_location) {
                $list = array();
                $params = array();
                if ($b_category) {
                    $params['sCategory'] = $category;
                }
                if ($b_city) {
                    $aCity = City::newInstance()->findByName($city);
                    if (count($aCity) == 0) {
                        $params['sCity'] = $city;
                        $list[] = '<a href="' . osc_search_url($params) . '"><span class="bc_city">' . $city . '</span></a>';
                    } else {
                        $aRegion = Region::newInstance()->findByPrimaryKey($aCity['fk_i_region_id']);
                        $params['sRegion'] = $aRegion['s_name'];
                        $list[] = '<a href="' . osc_search_url($params) . '"><span class="bc_region">' . $aRegion['s_name'] . '</span></a>';
                        $params['sCity'] = $aCity['s_name'];
                        $list[] = '<a href="' . osc_search_url($params) . '"><span class="bc_city">' . $aCity['s_name'] . '</span></a>';
                    }
//.........这里部分代码省略.........
开发者ID:oanav,项目名称:closetshare,代码行数:101,代码来源:index.php

示例7: twitter_breadcrumb

function twitter_breadcrumb($separator = '/')
{
    $breadcrumb = array();
    $text = '';
    $location = Rewrite::newInstance()->get_location();
    $section = Rewrite::newInstance()->get_section();
    $separator = '<span class="divider">' . trim($separator) . '</span>';
    $page_title = '<li><a href="' . osc_base_url() . '">' . osc_page_title() . '</a>' . $separator . '</li>';
    switch ($location) {
        case 'item':
            switch ($section) {
                case 'item_add':
                    break;
                default:
                    $aCategories = Category::newInstance()->toRootTree((string) osc_item_category_id());
                    $category = '';
                    if (count($aCategories) == 0) {
                        break;
                    }
                    foreach ($aCategories as $aCategory) {
                        $list[] = '<li><a href="' . osc_item_category_url($aCategory['pk_i_id']) . '">' . $aCategory['s_name'] . '</a>' . $separator . '</li>';
                    }
                    $category = implode('', $list);
                    break;
            }
            switch ($section) {
                case 'item_add':
                    $text = $page_title . '<li>' . __('Publish an item', 'twitter') . '</li>';
                    break;
                case 'item_edit':
                    $text = $page_title . '<li><a href="' . osc_item_url() . '">' . osc_item_title() . '</a>' . $separator . '</li><li>' . __('Edit your item', 'twitter') . '</li>';
                    break;
                case 'send_friend':
                    $text = $page_title . $category . '<li><a href="' . osc_item_url() . '">' . osc_item_title() . '</a>' . $separator . '</li><li>' . __('Send to a friend', 'twitter') . '</li>';
                    break;
                case 'contact':
                    $text = $page_title . $category . '<li><a href="' . osc_item_url() . '">' . osc_item_title() . '</a>' . $separator . '<li><li>' . __('Contact seller', 'twitter') . '</li>';
                    break;
                default:
                    $text = $page_title . $category . '<li>' . osc_item_title() . '</li>';
                    break;
            }
            break;
        case 'page':
            $text = $page_title . '<li>' . osc_static_page_title() . '</li>';
            break;
        case 'search':
            $region = Params::getParam('sRegion');
            $city = Params::getParam('sCity');
            $pattern = Params::getParam('sPattern');
            $category = osc_search_category_id();
            $category = count($category) == 1 ? $category[0] : '';
            $b_show_all = $pattern == '' && $category == '' && $region == '' && $city == '';
            $b_category = $category != '';
            $b_pattern = $pattern != '';
            $b_region = $region != '';
            $b_city = $city != '';
            $b_location = $b_region || $b_city;
            if ($b_show_all) {
                $text = $page_title . '<li>' . __('Search', 'twitter') . '</li>';
                break;
            }
            // init
            $result = $page_title;
            if ($b_category) {
                $list = array();
                $aCategories = Category::newInstance()->toRootTree($category);
                if (count($aCategories) > 0) {
                    $deep = 1;
                    foreach ($aCategories as $single) {
                        $list[] = '<li><a href="' . osc_item_category_url($single['pk_i_id']) . '">' . $single['s_name'] . '</a>' . $separator . '</li>';
                        $deep++;
                    }
                    // remove last link
                    if (!$b_pattern && !$b_location) {
                        $list[count($list) - 1] = preg_replace('|<li><a href.*?>(.*?)</a>.*?</li>|', '$01', $list[count($list) - 1]);
                    }
                    $result .= implode('', $list);
                }
            }
            if ($b_location) {
                $list = array();
                $params = array();
                if ($b_category) {
                    $params['sCategory'] = $category;
                }
                if ($b_city) {
                    $aCity = City::newInstance()->findByName($city);
                    if (count($aCity) == 0) {
                        $params['sCity'] = $city;
                        $list[] = '<li><a href="' . osc_search_url($params) . '">' . $city . '</a>' . $separator . '</li>';
                    } else {
                        $aRegion = Region::newInstance()->findByPrimaryKey($aCity['fk_i_region_id']);
                        $params['sRegion'] = $aRegion['s_name'];
                        $list[] = '<li><a href="' . osc_search_url($params) . '">' . $aRegion['s_name'] . '</a>' . $separator . '</li>';
                        $params['sCity'] = $aCity['s_name'];
                        $list[] = '<li><a href="' . osc_search_url($params) . '">' . $aCity['s_name'] . '</a>' . $separator . '</li>';
                    }
                    if (!$b_pattern) {
                        $list[count($list) - 1] = preg_replace('|<li><a href.*?>(.*?)</a>.*?</li>|', '$01', $list[count($list) - 1]);
//.........这里部分代码省略.........
开发者ID:ricktaylord,项目名称:osclass-themes,代码行数:101,代码来源:functions.php

示例8: doModel

 function doModel()
 {
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             break;
         case 'regions':
             //Return regions given a countryId
             $regions = Region::newInstance()->findByCountry(Params::getParam("countryId"));
             echo json_encode($regions);
             break;
         case 'cities':
             //Returns cities given a regionId
             $cities = City::newInstance()->findByRegion(Params::getParam("regionId"));
             echo json_encode($cities);
             break;
         case 'location':
             // This is the autocomplete AJAX
             $cities = City::newInstance()->ajax(Params::getParam("term"));
             echo json_encode($cities);
             break;
         case 'userajax':
             // This is the autocomplete AJAX
             $users = User::newInstance()->ajax(Params::getParam("term"));
             if (count($users) == 0) {
                 echo json_encode(array(0 => array('id' => '', 'label' => __('No results'), 'value' => __('No results'))));
             } else {
                 echo json_encode($users);
             }
             break;
         case 'date_format':
             echo json_encode(array('format' => Params::getParam('format'), 'str_formatted' => osc_format_date(date('Y-m-d H:i:s'), Params::getParam('format'))));
             break;
         case 'runhook':
             // run hooks
             $hook = Params::getParam('hook');
             if ($hook == '') {
                 echo json_encode(array('error' => 'hook parameter not defined'));
                 break;
             }
             switch ($hook) {
                 case 'item_form':
                     osc_run_hook('item_form', Params::getParam('catId'));
                     break;
                 case 'item_edit':
                     $catId = Params::getParam("catId");
                     $itemId = Params::getParam("itemId");
                     osc_run_hook("item_edit", $catId, $itemId);
                     break;
                 default:
                     osc_run_hook('ajax_admin_' . $hook);
                     break;
             }
             break;
         case 'categories_order':
             // Save the order of the categories
             osc_csrf_check(false);
             $aIds = Params::getParam('list');
             $orderParent = 0;
             $orderSub = 0;
             $catParent = 0;
             $error = 0;
             $catManager = Category::newInstance();
             $aRecountCat = array();
             foreach ($aIds as $id => $parent) {
                 if ($parent == 'root') {
                     $res = $catManager->updateOrder($id, $orderParent);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                     // find category
                     $auxCategory = Category::newInstance()->findByPrimaryKey($id);
                     // set parent category
                     $conditions = array('pk_i_id' => $id);
                     $array['fk_i_parent_id'] = NULL;
                     $res = $catManager->update($array, $conditions);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     } else {
                         if ($res == 1) {
                             // updated ok
                             $parentId = $auxCategory['fk_i_parent_id'];
                             if ($parentId) {
                                 // update parent category stats
                                 array_push($aRecountCat, $id);
                                 array_push($aRecountCat, $parentId);
                             }
                         }
                     }
                     $orderParent++;
                 } else {
                     if ($parent != $catParent) {
                         $catParent = $parent;
                         $orderSub = 0;
                     }
                     $res = $catManager->updateOrder($id, $orderSub);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                     // set parent category
//.........这里部分代码省略.........
开发者ID:jmcclenon,项目名称:Osclass,代码行数:101,代码来源:ajax.php

示例9: doModel

 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'create':
             // callign create view
             $aCountries = array();
             $aRegions = array();
             $aCities = array();
             $aCountries = Country::newInstance()->listAll();
             if (isset($aCountries[0]['pk_c_code'])) {
                 $aRegions = Region::newInstance()->getByCountry($aCountries[0]['pk_c_code']);
             }
             if (isset($aRegions[0]['pk_i_id'])) {
                 $aCities = City::newInstance()->listWhere("fk_i_region_id = %d", $aRegions[0]['pk_i_id']);
             }
             $this->_exportVariableToView("user", null);
             $this->_exportVariableToView("countries", $aCountries);
             $this->_exportVariableToView("regions", $aRegions);
             $this->_exportVariableToView("cities", $aCities);
             $this->_exportVariableToView("locales", OSCLocale::newInstance()->listAllEnabled());
             $this->doView("users/frm.php");
             break;
         case 'create_post':
             // creating the user...
             require_once LIB_PATH . 'osclass/UserActions.php';
             $userActions = new UserActions(true);
             $success = $userActions->add();
             switch ($success) {
                 case 1:
                     osc_add_flash_message(_m('The user has been created. We\'ve sent an activation e-mail'), 'admin');
                     break;
                 case 2:
                     osc_add_flash_message(_m('The user has been created and activated'), 'admin');
                     break;
                 case 3:
                     osc_add_flash_message(_m('Sorry, but that e-mail is already in use'), 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=users');
             break;
         case 'edit':
             // calling the edit view
             $aUser = array();
             $aCountries = array();
             $aRegions = array();
             $aCities = array();
             $aUser = $this->userManager->findByPrimaryKey(Params::getParam("id"));
             $aCountries = Country::newInstance()->listAll();
             $aRegions = array();
             if ($aUser['fk_c_country_code'] != '') {
                 $aRegions = Region::newInstance()->getByCountry($aUser['fk_c_country_code']);
             } else {
                 if (count($aCountries) > 0) {
                     $aRegions = Region::newInstance()->getByCountry($aCountries[0]['pk_c_code']);
                 }
             }
             $aCities = array();
             if ($aUser['fk_i_region_id'] != '') {
                 $aCities = City::newInstance()->listWhere("fk_i_region_id = %d", $aUser['fk_i_region_id']);
             } else {
                 if (count($aRegions) > 0) {
                     $aCities = City::newInstance()->listWhere("fk_i_region_id = %d", $aRegions[0]['pk_i_id']);
                 }
             }
             $this->_exportVariableToView("user", $aUser);
             $this->_exportVariableToView("countries", $aCountries);
             $this->_exportVariableToView("regions", $aRegions);
             $this->_exportVariableToView("cities", $aCities);
             $this->_exportVariableToView("locales", OSCLocale::newInstance()->listAllEnabled());
             $this->doView("users/frm.php");
             break;
         case 'edit_post':
             // edit post
             require_once LIB_PATH . 'osclass/UserActions.php';
             $userActions = new UserActions(true);
             $success = $userActions->edit(Params::getParam("id"));
             switch ($success) {
                 case 1:
                     osc_add_flash_message(_m('Passwords don\'t match'), 'admin');
                     break;
                 case 2:
                     osc_add_flash_message(_m('The user has been updated and activated'), 'admin');
                     break;
                 default:
                     osc_add_flash_message(_m('The user has been updated'), 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=users');
             break;
         case 'activate':
             //activate
             $iUpdated = 0;
             $userId = Params::getParam('id');
             if (!is_array($userId)) {
                 osc_add_flash_message(_m('User id isn\'t in the correct format'), 'admin');
             }
             foreach ($userId as $id) {
                 $conditions = array('pk_i_id' => $id);
//.........这里部分代码省略.........
开发者ID:hashemgamal,项目名称:OSClass,代码行数:101,代码来源:users.php

示例10: doModel

 function doModel()
 {
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             break;
         case 'regions':
             //Return regions given a countryId
             $regions = Region::newInstance()->getByCountry(Params::getParam("countryId"));
             echo json_encode($regions);
             break;
         case 'cities':
             //Returns cities given a regionId
             $cities = City::newInstance()->getByRegion(Params::getParam("regionId"));
             echo json_encode($cities);
             break;
         case 'location':
             // This is the autocomplete AJAX
             $cities = City::newInstance()->ajax(Params::getParam("term"));
             echo json_encode($cities);
             break;
         case 'alerts':
             // Allow to register to an alert given (not sure it's used on admin)
             $alert = Params::getParam("alert");
             $email = Params::getParam("email");
             $userid = Params::getParam("userid");
             if ($alert != '' && $email != '') {
                 if (preg_match("/^[_a-z0-9-+]+(\\.[_a-z0-9-+]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})\$/", $email)) {
                     Alerts::newInstance()->createAlert($userid, $email, $alert);
                     echo "1";
                 } else {
                     echo '0';
                 }
                 return true;
             }
             echo '0';
             return false;
             break;
         case 'runhook':
             //Run hooks
             $hook = Params::getParam("hook");
             switch ($hook) {
                 case 'item_form':
                     $catId = Params::getParam("catId");
                     if ($catId != '') {
                         osc_run_hook("item_form", $catId);
                     } else {
                         osc_run_hook("item_form");
                     }
                     break;
                 case 'item_edit':
                     $catId = Params::getParam("catId");
                     $itemId = Params::getParam("itemId");
                     osc_run_hook("item_edit", $catId, $itemId);
                     break;
                 default:
                     if ($hook == '') {
                         return false;
                     } else {
                         osc_run_hook($hook);
                     }
                     break;
             }
             break;
         case 'custom':
             // Execute via AJAX custom file
             $ajaxfile = Params::getParam("ajaxfile");
             if ($ajaxfile != '') {
                 require_once osc_plugins_path() . $ajaxfile;
             } else {
                 echo json_encode(array('error' => __('no action defined')));
             }
             break;
         default:
             echo json_encode(array('error' => __('no action defined')));
             break;
     }
 }
开发者ID:hashemgamal,项目名称:OSClass,代码行数:78,代码来源:ajax.php

示例11: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'dashboard':
             //dashboard...
             $max_items = Params::getParam('max_items') != '' ? Params::getParam('max_items') : 5;
             $aItems = Item::newInstance()->findByUserIDEnabled(osc_logged_user_id(), 0, $max_items);
             //calling the view...
             $this->_exportVariableToView('items', $aItems);
             $this->_exportVariableToView('max_items', $max_items);
             $this->doView('user-dashboard.php');
             break;
         case 'profile':
             //profile...
             $user = User::newInstance()->findByPrimaryKey(osc_logged_user_id());
             $aCountries = Country::newInstance()->listAll();
             $aRegions = array();
             if ($user['fk_c_country_code'] != '') {
                 $aRegions = Region::newInstance()->findByCountry($user['fk_c_country_code']);
             } elseif (count($aCountries) > 0) {
                 $aRegions = Region::newInstance()->findByCountry($aCountries[0]['pk_c_code']);
             }
             $aCities = array();
             if ($user['fk_i_region_id'] != '') {
                 $aCities = City::newInstance()->findByRegion($user['fk_i_region_id']);
             } else {
                 if (count($aRegions) > 0) {
                     $aCities = City::newInstance()->findByRegion($aRegions[0]['pk_i_id']);
                 }
             }
             //calling the view...
             $this->_exportVariableToView('countries', $aCountries);
             $this->_exportVariableToView('regions', $aRegions);
             $this->_exportVariableToView('cities', $aCities);
             $this->_exportVariableToView('user', $user);
             $this->_exportVariableToView('locales', OSCLocale::newInstance()->listAllEnabled());
             $this->doView('user-profile.php');
             break;
         case 'profile_post':
             //profile post...
             osc_csrf_check();
             $userId = Session::newInstance()->_get('userId');
             require_once LIB_PATH . 'osclass/UserActions.php';
             $userActions = new UserActions(false);
             $success = $userActions->edit($userId);
             if ($success == 1 || $success == 2) {
                 osc_add_flash_ok_message(_m('Your profile has been updated successfully'));
             } else {
                 osc_add_flash_error_message($success);
             }
             $this->redirectTo(osc_user_profile_url());
             break;
         case 'alerts':
             //alerts
             $aAlerts = Alerts::newInstance()->findByUser(Session::newInstance()->_get('userId'), false);
             $user = User::newInstance()->findByPrimaryKey(Session::newInstance()->_get('userId'));
             foreach ($aAlerts as $k => $a) {
                 $array_conditions = (array) json_decode($a['s_search']);
                 //                                            $search = Search::newInstance();
                 $search = new Search();
                 $search->setJsonAlert($array_conditions);
                 $search->limit(0, 3);
                 $aAlerts[$k]['items'] = $search->doSearch();
             }
             $this->_exportVariableToView('alerts', $aAlerts);
             View::newInstance()->_reset('alerts');
             $this->_exportVariableToView('user', $user);
             $this->doView('user-alerts.php');
             break;
         case 'change_email':
             //change email
             $this->doView('user-change_email.php');
             break;
         case 'change_email_post':
             //change email post
             osc_csrf_check();
             if (!osc_validate_email(Params::getParam('new_email'))) {
                 osc_add_flash_error_message(_m('The specified e-mail is not valid'));
                 $this->redirectTo(osc_change_user_email_url());
             } else {
                 $user = User::newInstance()->findByEmail(Params::getParam('new_email'));
                 if (!isset($user['pk_i_id'])) {
                     $userEmailTmp = array();
                     $userEmailTmp['fk_i_user_id'] = Session::newInstance()->_get('userId');
                     $userEmailTmp['s_new_email'] = Params::getParam('new_email');
                     UserEmailTmp::newInstance()->insertOrUpdate($userEmailTmp);
                     $code = osc_genRandomPassword(30);
                     $date = date('Y-m-d H:i:s');
                     $userManager = new User();
                     $userManager->update(array('s_pass_code' => $code, 's_pass_date' => $date, 's_pass_ip' => $_SERVER['REMOTE_ADDR']), array('pk_i_id' => Session::newInstance()->_get('userId')));
                     $validation_url = osc_change_user_email_confirm_url(Session::newInstance()->_get('userId'), $code);
                     osc_run_hook('hook_email_new_email', Params::getParam('new_email'), $validation_url);
                     $this->redirectTo(osc_user_profile_url());
                 } else {
                     osc_add_flash_error_message(_m('The specified e-mail is already in use'));
                     $this->redirectTo(osc_change_user_email_url());
                 }
             }
             break;
         case 'change_username':
//.........这里部分代码省略.........
开发者ID:naneri,项目名称:Osclass,代码行数:101,代码来源:user.php

示例12: region_select

 public static function region_select($regions = null, $item = null)
 {
     // if have input text instead of select
     if (Session::newInstance()->_getForm('region') != '') {
         $regions = null;
     } else {
         if ($regions == null) {
             $regions = osc_get_regions();
         }
     }
     if ($item == null) {
         $item = osc_item();
     }
     if (count($regions) >= 1) {
         if (Session::newInstance()->_getForm('regionId') != "") {
             $item['fk_i_region_id'] = Session::newInstance()->_getForm('regionId');
             if (Session::newInstance()->_getForm('countryId') != "") {
                 $regions = Region::newInstance()->getByCountry(Session::newInstance()->_getForm('countryId'));
             }
         }
         parent::generic_select('regionId', $regions, 'pk_i_id', 's_name', __('Select a region...'), isset($item['fk_i_region_id']) ? $item['fk_i_region_id'] : null);
         return true;
         //            } else if ( count($regions) == 1 ) {
         //                if( Session::newInstance()->_getForm('regionId') != "" ) {
         //                    $item['fk_i_region_id'] = Session::newInstance()->_getForm('regionId');
         //                }
         //                parent::generic_input_hidden('regionId', (isset($item['fk_i_region_id'])) ? $item['fk_i_region_id'] : $regions[0]['pk_i_id']) ;
         //                echo '<span>' .$regions[0]['s_name'] . '</span>';
         //                return false ;
     } else {
         if (Session::newInstance()->_getForm('region') != "") {
             $item['s_region'] = Session::newInstance()->_getForm('region');
         }
         parent::generic_input_text('region', isset($item['s_region']) ? $item['s_region'] : null);
         return true;
     }
 }
开发者ID:nsswaga,项目名称:OSClass,代码行数:37,代码来源:Item.form.class.php

示例13: osc_validate_location

/**
 * Validate if exist $city, $region, $country in db
 *
 * @param string $city
 * @param string $region
 * @param string $country
 * @return boolean
 */
function osc_validate_location($city, $sCity, $region, $sRegion, $country, $sCountry)
{
    if (osc_validate_nozero($city) && osc_validate_nozero($region) && osc_validate_text($country, 2)) {
        $data = Country::newInstance()->findByCode($country);
        $countryId = $data['pk_c_code'];
        if ($countryId) {
            $data = Region::newInstance()->findByPrimaryKey($region);
            $regionId = $data['pk_i_id'];
            if ($data['b_active'] == 1) {
                $data = City::newInstance()->findByPrimaryKey($city);
                if ($data['b_active'] == 1 && $data['fk_i_region_id'] == $regionId && strtolower($data['fk_c_country_code']) == strtolower($countryId)) {
                    return true;
                }
            }
        }
    } else {
        if (osc_validate_nozero($region) && osc_validate_text($country, 2) && $sCity != "") {
            return true;
        } else {
            if ($sRegion != "" && osc_validate_text($country, 2) && $sCity != "") {
                return true;
            } else {
                if ($sRegion != "" && $sCountry != "" && $sCity != "") {
                    return true;
                }
            }
        }
    }
    return false;
}
开发者ID:acharei,项目名称:OSClass,代码行数:38,代码来源:hValidate.php

示例14: prepareData

        function prepareData($is_add)
        {
            $input = array();

            if ( $is_add ) {
                $input['s_secret']    = osc_genRandomPassword();
                $input['dt_reg_date'] = date('Y-m-d H:i:s');
            } else {
                $input['dt_mod_date'] = date('Y-m-d H:i:s');
            }

            //only for administration, in the public website this two params are edited separately
            if ( $this->is_admin || $is_add ) {
                $input['s_email'] = Params::getParam('s_email');

                //if we want to change the password
                if( Params::getParam('s_password', false, false) != '') {
                    $input['s_password'] = osc_hash_password(Params::getParam('s_password', false, false));
                }
                $input['s_username']     = osc_sanitize_username(Params::getParam('s_username'));
            }

            $input['s_name']         = trim(Params::getParam('s_name'));
            $input['s_website']      = trim(Params::getParam('s_website'));
            $input['s_phone_land']   = trim(Params::getParam('s_phone_land'));
            $input['s_phone_mobile'] = trim(Params::getParam('s_phone_mobile'));

            if(strtolower(substr($input['s_website'], 0, 4))!=='http') {
                $input['s_website'] = 'http://'.$input['s_website'];
            }
            $input['s_website'] = osc_sanitize_url($input['s_website']);
            if ( ! osc_validate_url($input['s_website'])) $input['s_website'] = '';

            //locations...
            $country = Country::newInstance()->findByCode( Params::getParam('countryId') );
            if(count($country) > 0) {
                $countryId   = $country['pk_c_code'];
                $countryName = $country['s_name'];
            } else {
                $countryId   = null;
                $countryName = Params::getParam('country');
            }

            if( intval( Params::getParam('regionId') ) ) {
                $region = Region::newInstance()->findByPrimaryKey( Params::getParam('regionId') );
                if( count($region) > 0 ) {
                    $regionId   = $region['pk_i_id'];
                    $regionName = $region['s_name'];
                }
            } else {
                $regionId   = null;
                $regionName = Params::getParam('region');
            }

            if( intval( Params::getParam('cityId') ) ) {
                $city = City::newInstance()->findByPrimaryKey( Params::getParam('cityId') );
                if( count($city) > 0 ) {
                    $cityId   = $city['pk_i_id'];
                    $cityName = $city['s_name'];
                }
            } else {
                $cityId   = null;
                $cityName = Params::getParam('city');
            }

            $input['fk_c_country_code'] = $countryId;
            $input['s_country'] = $countryName;
            $input['fk_i_region_id'] = $regionId;
            $input['s_region']       = $regionName;
            $input['fk_i_city_id']   = $cityId;
            $input['s_city']         = $cityName;
            $input['s_city_area']    = Params::getParam('cityArea');
            $input['s_address']      = Params::getParam('address');
            $input['s_zip']          = Params::getParam('zip');
            $input['d_coord_lat']    = (Params::getParam('d_coord_lat')  != '') ? Params::getParam('d_coord_lat') : null;
            $input['d_coord_long']   = (Params::getParam('d_coord_long') != '') ? Params::getParam('d_coord_long') : null;
            $input['b_company']      = (Params::getParam('b_company') != '' && Params::getParam('b_company') != 0) ? 1 : 0;

            return($input);
        }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:80,代码来源:UserActions.php

示例15: prepareData

 function prepareData($is_add)
 {
     $input = array();
     if ($is_add) {
         $input['s_secret'] = osc_genRandomPassword();
         $input['dt_reg_date'] = date('Y-m-d H:i:s');
     } else {
         $input['dt_mod_date'] = date('Y-m-d H:i:s');
     }
     //only for administration, in the public website this two params are edited separately
     if ($this->is_admin || $is_add) {
         $input['s_email'] = Params::getParam('s_email');
         if (Params::getParam('s_password', false, false) != Params::getParam('s_password2', false, false)) {
             return 1;
         }
         //if we want to change the password
         if (Params::getParam('s_password', false, false) != '') {
             $input['s_password'] = sha1(Params::getParam('s_password', false, false));
         }
     }
     $input['s_name'] = Params::getParam('s_name');
     $input['s_website'] = Params::getParam('s_website');
     $input['s_phone_land'] = Params::getParam('s_phone_land');
     $input['s_phone_mobile'] = Params::getParam('s_phone_mobile');
     //locations...
     $country = Country::newInstance()->findByCode(Params::getParam('countryId'));
     if (count($country) > 0) {
         $countryId = $country['pk_c_code'];
         $countryName = $country['s_name'];
     } else {
         $countryId = null;
         $countryName = null;
     }
     if (intval(Params::getParam('regionId'))) {
         $region = Region::newInstance()->findByPrimaryKey(Params::getParam('regionId'));
         if (count($region) > 0) {
             $regionId = $region['pk_i_id'];
             $regionName = $region['s_name'];
         }
     } else {
         $regionId = null;
         $regionName = Params::getParam('region');
     }
     if (intval(Params::getParam('cityId'))) {
         $city = City::newInstance()->findByPrimaryKey(Params::getParam('cityId'));
         if (count($city) > 0) {
             $cityId = $city['pk_i_id'];
             $cityName = $city['s_name'];
         }
     } else {
         $cityId = null;
         $cityName = Params::getParam('city');
     }
     $input['fk_c_country_code'] = $countryId;
     $input['s_country'] = $countryName;
     $input['fk_i_region_id'] = $regionId;
     $input['s_region'] = $regionName;
     $input['fk_i_city_id'] = $cityId;
     $input['s_city'] = $cityName;
     $input['s_city_area'] = Params::getParam('cityArea');
     $input['s_address'] = Params::getParam('address');
     $input['b_company'] = Params::getParam('b_company') != '' && Params::getParam('b_company') != 0 ? 1 : 0;
     return $input;
 }
开发者ID:randomecho,项目名称:OSClass,代码行数:64,代码来源:UserActions.php


注:本文中的Region::newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。