本文整理匯總了PHP中Model_Users::getByUsername方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Users::getByUsername方法的具體用法?PHP Model_Users::getByUsername怎麽用?PHP Model_Users::getByUsername使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Users
的用法示例。
在下文中一共展示了Model_Users::getByUsername方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createUser
public static function createUser($data)
{
$db = JO_Db::getDefaultAdapter();
if (!$data['username'] || Model_Users::getByUsername($data['username'])) {
return false;
}
if (!$data['email'] || Model_Users::getByEmail($data['email'])) {
return false;
}
$db->insert(Model_Users::getPrefixDB() . 'users', array('username' => $data['username'], 'password' => $data['password'], 'email' => $data['email'], 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'firmname' => $data['firmname'], 'profile_title' => $data['profile_title'], 'profile_desc' => $data['profile_desc'], 'register_datetime' => $data['register_datetime'], 'status' => 'activate'));
$user_id = $db->lastInsertId();
if ($user_id) {
$upload_path = BASE_PATH . '/uploads';
$user_path = '/users/' . JO_Date::getInstance($data['register_datetime'], 'yy/mm/')->toString() . $user_id . '/';
$upload_path .= $user_path;
if ($data['avatar'] && @getimagesize($data['avatar'])) {
$name = basename($data['avatar']);
if (copy($data['avatar'], $upload_path . $name)) {
$db->update('users', array('avatar' => $user_path . $name), array('user_id' => $user_id));
}
}
if ($data['homeimage'] && @getimagesize($data['homeimage'])) {
$name = basename($data['homeimage']);
if (copy($data['homeimage'], $upload_path . $name)) {
$db->update('users', array('homeimage' => $user_path . $name), array('user_id' => $user_id));
}
}
return Model_Users::getUser($user_id);
}
}
示例2: indexAction
public function indexAction()
{
$where = '';
$category = null;
if ($this->getRequest()->getQuery('username')) {
$userinfo = Model_Users::getByUsername($this->getRequest()->getQuery('username'));
if ($userinfo) {
$where = "users.username = '" . $this->getRequest()->getQuery('username') . "'";
}
}
if ($this->getRequest()->getQuery('category')) {
$catinfo = Model_Categories::get($this->getRequest()->getQuery('category'));
if ($catinfo) {
$category = $this->getRequest()->getQuery('category');
}
}
$items = Model_Items::getAll($category, 0, 20, 'id desc', $where);
$this->view->item = array();
if ($items) {
$model_images = new Model_Images();
$categories = Model_Categories::get_all();
foreach ($items as $item) {
$categories_string = '';
if ($category) {
foreach ($item['categories'] as $cats) {
if (in_array($category, $cats)) {
foreach ($cats as $cat) {
if (isset($categories[$cat]['name'])) {
$categories_string .= $categories_string ? ' › ' : '';
$categories_string .= $categories[$cat]['name'];
}
}
break;
}
}
} else {
$cats = array_pop($item['categories']);
if ($cats && is_array($cats)) {
foreach ($cats as $cat) {
if (isset($categories[$cat]['name'])) {
$categories_string .= $categories_string ? ' › ' : '';
$categories_string .= $categories[$cat]['name'];
}
}
}
}
if ((int) JO_Registry::get($item['module'] . '_items_preview_width') && (int) JO_Registry::get($item['module'] . '_items_preview_height')) {
$item['theme_preview_thumbnail'] = $this->getRequest()->getBaseUrl() . $model_images->resize($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'), JO_Registry::forceGet($item['module'] . '_items_preview_height'), true);
} elseif ((int) JO_Registry::get($item['module'] . '_items_preview_width')) {
$item['theme_preview_thumbnail'] = $this->getRequest()->getBaseUrl() . $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'));
} elseif ((int) JO_Registry::get($item['module'] . '_items_preview_height')) {
$item['theme_preview_thumbnail'] = $this->getRequest()->getBaseUrl() . $model_images->resizeHeight($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_height'));
} else {
$item['theme_preview_thumbnail'] = false;
}
$this->view->item[] = array('title' => $item['name'], 'link' => WM_Router::create($this->getRequest()->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&item_id=' . $item['id']), 'description' => html_entity_decode($item['description'], ENT_QUOTES, 'utf-8'), 'author' => $item['username'], 'category' => $categories_string, 'guid' => $item['id'], 'enclosure' => $item['theme_preview_thumbnail'], 'pubDate' => JO_Date::getInstance($item['datetime'], JO_Date::RSS_FULL, true)->toString());
}
}
echo $this->renderScript('rss');
}
示例3: loginAction
public function loginAction()
{
if (JO_Session::get('user_id')) {
$this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=dashboard'));
}
if (JO_Session::issetKey('msg_error')) {
$this->view->check_error = JO_Session::get('msg_error');
$this->view->user = JO_Session::get('data');
JO_Session::clear('msg_error');
JO_Session::clear('data');
}
$this->view->usersCount = Model_Users::countUsers();
$this->view->itemsCount = Model_Items::countItems();
$this->getLayout()->meta_title = $this->translate('Login');
$this->getLayout()->meta_description = $this->translate('Login');
$request = $this->getRequest();
if ($request->isPost()) {
$result = Model_Users::checkLogin($request->getPost('username'), $request->getPost('password'));
if ($result) {
$result['following'] = Model_Users::getFollowers($result['user_id']);
$groups = unserialize($result['groups']);
if (is_array($groups) and count($groups) > 1) {
unset($result['groups']);
$fetch_all = Model_Users::getGroups($groups);
$result['access'] = array();
if ($fetch_all) {
foreach ($fetch_all as $row) {
$modules = unserialize($row['rights']);
if (is_array($modules)) {
foreach ($modules as $module => $ison) {
$result['access'][$module] = $module;
}
}
}
}
}
if (isset($result['access']) && count($result['access'])) {
$result['is_admin'] = true;
}
JO_Session::set($result);
if (JO_Session::get('redirect')) {
$this->redirect(JO_Session::get('redirect'));
} elseif ($request->getServer('HTTP_REFERER')) {
$this->redirect($request->getServer('HTTP_REFERER'));
} else {
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=dashboard'));
}
} else {
JO_Session::set('msg_error', $this->translate('Invalid username or password or the account is not activated.'));
$request->setParams('username', $request->getPost('username'));
JO_Session::set('data', $request->getParams());
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
}
}
if ($request->getRequest('command') == 'activate' and $request->getRequest('user') and $request->getRequest('key')) {
if (Model_Users::checkActivation($request->getRequest('user'), $request->getRequest('key'))) {
Model_Users::Activate($request->getRequest('user'));
$result = Model_Users::getByUsername($request->getRequest('user'));
if ($result) {
$groups = unserialize($result['groups']);
if (is_array($groups) and count($groups) > 1) {
unset($result['groups']);
$fetch_all = Model_Users::getGroups($groups);
$result['access'] = array();
if ($fetch_all) {
foreach ($fetch_all as $row) {
$modules = unserialize($row['rights']);
if (is_array($modules)) {
foreach ($modules as $module => $ison) {
$result['access'][$module] = $module;
}
}
}
}
}
if (isset($result['access']) && count($result['access'])) {
$result['is_admin'] = true;
}
JO_Session::set($result);
}
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=verify/completed/yes'));
}
}
$facebook = new WM_Facebook_Api(array('appId' => JO_Registry::forceGet('facebook_appid'), 'secret' => JO_Registry::forceGet('facebook_secret')));
$this->view->facebook_link = $facebook->getLoginUrl(array('redirect_uri' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=callback_facebook'), 'req_perms' => JO_Registry::forceGet('facebook_req_perms'), 'scope' => JO_Registry::forceGet('facebook_req_perms')));
$this->view->lost_username = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=lost_username');
$this->view->reset_password = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=reset_password');
$this->view->registration = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=registration');
$this->view->children = array();
$this->view->children['header_part'] = 'layout/header_part';
$this->view->children['footer_part'] = 'layout/footer_part';
}
示例4: formAction
public function formAction()
{
$request = $this->getRequest();
if (!JO_Session::get('user_id')) {
JO_Session::set('msg_error', $this->translate('You must be logged to upload an item'));
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
}
if (JO_Session::get('quiz') != 'true') {
JO_Session::set('msg_error', $this->translate('In order to upload your files for sale first you have to pass our quiz.'));
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=quiz'));
}
if ($request->getRequest('form')) {
$category_id = $request->getRequest('form');
}
$redir_link = WM_Router::create($request->getBaseUrl() . '?controller=upload');
if (!$category_id) {
$this->redirect($redir_link);
}
$this->getLayout()->meta_title = $this->translate('Item upload');
$this->getLayout()->meta_description = $this->translate('Item upload');
$mainCategories = Model_Categories::getMain();
$cnt = count($mainCategories);
for ($i = 0; $i < $cnt; $i++) {
$mainCategories[$i]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=upload&action=get_categories&category_id=' . $mainCategories[$i]['id']);
}
$category_info = Model_Categories::get($category_id);
$has_category = JO_Array::multi_array_search($mainCategories, 'id', $category_id);
if (!$category_info) {
JO_Session::set('msg_error', $this->translate('You have choosen a non existing category'));
$this->redirect($redir_link);
} elseif (empty($has_category)) {
JO_Session::set('msg_error', $this->translate('You have choosen a non existing category'));
$this->redirect($redir_link);
}
if (JO_Session::get('msg_error')) {
$this->view->error = JO_Session::get('msg_error');
JO_Session::clear('msg_error');
}
if (JO_Session::get('data')) {
$this->view->d = JO_Session::get('data');
JO_Session::clear('data');
}
$fileTypes = JO_Registry::get('upload_theme');
$types = '';
if ($fileTypes) {
foreach ($fileTypes as $type) {
$tp = explode(',', $type);
foreach ($tp as $t) {
$types .= '*.' . $t . ';';
}
}
}
$this->view->sel_category = $category_id;
$this->view->mainCategories = $mainCategories;
$allCategories = Model_Categories::getWithChilds();
$categoriesSelect = Model_Categories::generateSelect($allCategories, $category_id, $category_id);
if ($categoriesSelect) {
$categories = explode('|', $categoriesSelect);
foreach ($categories as $category) {
if (!empty($category)) {
$c = explode('>', $category);
$this->view->categoriesSelect[] = array('id' => $c[0], 'name' => trim($c[1]));
}
}
}
$this->view->fileTypes = $types;
$this->view->attributes = Model_Attributes::getAllWithCategories("attributes_categories.categories LIKE '%," . (int) $category_id . ",%'");
$fileTypes_allow = JO_Registry::get('upload_theme');
$allow_archives = array();
if (isset($fileTypes_allow['archives'])) {
$ew = explode(',', $fileTypes_allow['archives']);
foreach ($ew as $ar) {
$allow_archives[] = '.' . strtolower($ar);
}
}
$allow_images = array();
if (isset($fileTypes_allow['images'])) {
$ew = explode(',', $fileTypes_allow['images']);
foreach ($ew as $ar) {
$allow_images[] = '.' . strtolower($ar);
}
}
$this->view->uploaded_files = JO_Session::get('uploaded_files');
$this->view->uploaded_arhives = JO_Session::get('uploaded_arhives');
$this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Upload')));
$user = Model_Users::getByUsername(JO_Session::get('username'));
$this->view->author_header = Helper_Author::authorHeader($user);
$this->view->action_upload = WM_Router::create($request->getBaseUrl() . '?controller=upload&action=upload');
$this->view->autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=items&action=auto');
$this->view->total_sales_cnt = JO_Session::get('sales');
$this->view->total_balance = WM_Currency::format(JO_Session::get('total'));
$this->view->percent = Model_Percentes::getPercentRow($user);
$help = Model_Pages::get(JO_Registry::forceGet('page_upload_item'));
if ($help) {
$this->view->page_upload_item = array('name' => $help['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $help['id'] . '&name=' . WM_Router::clearName($help['name'])));
}
$this->view->file_upload = WM_Router::create($request->getBaseUrl() . '?module=themes&controller=upload&action=doupload');
$this->view->children = array();
$this->view->children['header_part'] = 'layout/header_part';
$this->view->children['footer_part'] = 'layout/footer_part';
//.........這裏部分代碼省略.........
示例5: returnFollowing
public static function returnFollowing($follower, $owner, $followers = false)
{
$view = JO_View::getInstance();
$model_images = new Helper_Images();
$request = JO_Request::getInstance();
$list_type = $request->getParam('list_type');
$user = Model_Users::getByUsername($follower['username']);
$view->badges = self::userBadges($user);
if ($user['avatar']) {
$user['avatar'] = $model_images->resize($user['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true);
} else {
$user['avatar'] = 'data/themes/images/noavatar.png';
}
$user['portfolio_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username=' . str_replace('&', '-', $user['username']));
$log_user = JO_Session::get('user_id');
if ($log_user) {
$following = JO_Array::multi_array_search(JO_Session::get('following'), 'follow_id', $user['user_id']);
if ($following) {
$user['follow_href_name'] = $view->translate('Unfollow');
$user['follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=unfollow&username=' . str_replace('&', '-', $user['username']));
} elseif ($log_user != $user['user_id']) {
$user['follow_href_name'] = $view->translate('Follow');
$user['follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&username=' . str_replace('&', '-', $user['username']));
}
}
$view->user = $user;
$user_items = Model_Items::getByUser($user['user_id'], 0, 3, 'rand()');
if (empty($user_items)) {
$user_items = array(array('no_items' => true, 'thumbnail' => 'data/themes/images/missing-item.png', 'module' => 'themes'));
}
$view->user_items = array();
if ($user_items) {
foreach ($user_items as $item) {
if (isset($item['demo_url'])) {
$item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?controller=demo&href=' . $item['demo_url']);
}
$view->user_items[] = Helper_Items::returnViewIndex($item);
}
}
return $view->renderByModule('single_user/following', 'users', 'themes');
}