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


PHP Users::findOne方法代码示例

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


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

示例1: add

 /**
  * Validates data submitted in the add form. If the validation fails,
  * displays the add page. Otherwise, creates a new order, saves it and
  * its products to the database and clears the 'cart' session variable. 
  * Redirects to the front page.
  */
 public static function add()
 {
     $params = $_POST;
     date_default_timezone_set('Europe/Helsinki');
     $attributes = array('user_id' => $params['user_id'], 'first_name' => $params['first_name'], 'last_name' => $params['last_name'], 'phone_number' => $params['phone_number'], 'street_address' => $params['street_address'], 'postal_code' => $params['postal_code'], 'city' => $params['city'], 'delivery_method' => $params['delivery_method']);
     $validator = self::order_validator($attributes);
     if ($validator->validate()) {
         $order = new Orders(array('user_id' => $attributes['user_id'], 'order_time' => date('d-m-Y H:i:s'), 'actual_delivery_time' => null, 'delivery_address' => $attributes['street_address'] . ', ' . $attributes['postal_code'] . ' ' . $attributes['city'], 'delivery_method' => $attributes['delivery_method'], 'total_price' => $_SESSION['cart']['price'], 'status' => 'Jonossa'));
         if (!$params['user_id']) {
             $user = array('user_id' => null, 'first_name' => $params['first_name'], 'last_name' => $params['last_name'], 'phone_number' => $params['phone_number']);
             $order->user_id = null;
             $order->user_info = json_encode($user);
         } else {
             $order->user_info = json_encode(Users::findOne($_SESSION['user']));
         }
         if ($order->delivery_method == 'Nouto') {
             $order->agreed_delivery_time = date('d-m-Y H:i:s', strtotime('+15 minutes', strtotime($order->order_time)));
         } else {
             $order->agreed_delivery_time = date('d-m-Y H:i:s', strtotime('+60 minutes', strtotime($order->order_time)));
         }
         $order_id = $order->save();
         self::set_order_products($order_id, $_SESSION['cart']['items']);
         $_SESSION['cart'] = null;
         Redirect::to('/', array('message' => 'Tilauksesi on lähetetty, kiitos!'));
     } else {
         View::make('order/add.html', array('errors' => $validator->errors(), 'user' => $attributes));
     }
 }
开发者ID:nadeka,项目名称:pizzataivas,代码行数:34,代码来源:orders_controller.php

示例2: get_user_logged_in

 public static function get_user_logged_in()
 {
     if (isset($_SESSION['user'])) {
         $user_id = $_SESSION['user'];
         return Users::findOne($user_id);
     }
     return;
 }
开发者ID:nadeka,项目名称:pizzataivas,代码行数:8,代码来源:base_controller.php

示例3: isUserSimple

 public static function isUserSimple($id)
 {
     if (Users::findOne(['id' => $id, 'activate' => '1', 'role' => 1])) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:pelos6,项目名称:miAppYII,代码行数:8,代码来源:User.php

示例4: isUserMaestro

 public static function isUserMaestro($id)
 {
     if (Users::findOne(['id' => $id, 'activate' => '1', 'role' => 'maestro'])) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:erpachecomo,项目名称:TuPortalPersonal,代码行数:8,代码来源:User.php

示例5: getUser

/**
 * getUser
 * Get user info from db or save fb data to db
 *
 * @param array $fb_user returned by FB request
 *
 * @return object
 **/
function getUser($fb_user)
{
    // check user exists in DB
    $user = Users::findOne($fb_user['id']);
    if (!$user) {
        // save user info
        $user = Users::create();
        $user->id = $fb_user['id'];
        $user->name = $fb_user['name'];
        $user->email = $fb_user['email'];
        $user->save();
    }
    return $user;
}
开发者ID:kxopa,项目名称:slimfb,代码行数:22,代码来源:helpers.php

示例6: delete

 /**
  * Delete project
  *
  * @param void
  * @return null
  */
 function delete()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $pid = get_id();
     $u = Users::findOne(array("conditions" => "personal_project_id = {$pid}"));
     if ($u) {
         //flash_error("id: $pid, u: ".$u->getId());
         ajx_current("empty");
         flash_error(lang('cannot delete personal project'));
         return;
         //$this->redirectTo('administration', 'projects');
     }
     $project = Projects::findById(get_id());
     if (!$project instanceof Project) {
         flash_error(lang('project dnx'));
         ajx_current("empty");
         return;
         //$this->redirectTo('administration', 'projects');
     }
     // if
     if (!$project->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
         //$this->redirectToReferer(get_url('administration', 'projects'));
     }
     // if
     if (!array_var($_GET, 'confirm')) {
         tpl_assign('project', $project);
         $this->setTemplate('pre_delete');
         return;
     }
     ajx_current("empty");
     try {
         $id = $project->getId();
         $name = $project->getName();
         DB::beginWork();
         $project->delete();
         CompanyWebsite::instance()->setProject(null);
         ApplicationLogs::createLog($project, null, ApplicationLogs::ACTION_DELETE);
         DB::commit();
         flash_success(lang('success delete project', $project->getName()));
         evt_add("workspace deleted", array("id" => $id, "name" => $name));
         ajx_current("start");
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
         ajx_current("empty");
     }
     // try
     //$this->redirectTo('administration', 'projects');
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:62,代码来源:ProjectController.class.php

示例7: get_id

			echo(lang('no access permissions'));
			?><br><a href="<?php echo ROOT_URL?>/index.php?c=access&a=index" target="_top">Go back to Feng Office</a><?php
			return;
		}

		$id = get_id();
		if ($id>0){
			$account = MailAccounts::findById($id);
		}
		else{ 
			$email_address = array_var($_GET, 'email');			
			$user_name = array_var($_GET, 'username');
			if (isset ($email_address) && isset ($user_name)){
				$user_conditions = array("conditions" => array("`username`='".$user_name."'"));
			
				$user = Users::findOne($user_conditions);
			
				if (!isset ($user)){	
					echo(lang('cant find user'));
					?><br><a href="<?php echo ROOT_URL?>/index.php?c=access&a=index" target="_top">Go back to Feng Office</a><?php 		
					return;
				}			
											
				$account_conditions = array("conditions" => array("`email_addr`='".$email_address."' AND `user_id`='".$user->getId()."'"));
				$account = MailAccounts::findOne($account_conditions);
				if (!isset ($account)){		
					echo(lang('cant find account'));
					?><br><a href="<?php echo ROOT_URL?>/index.php?c=access&a=index" target="_top">Go back to Feng Office</a><?php
					return;
				}					
			} 
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:mailsyncscript.php

示例8: replace_user_link_callback

/**
 * Call back function for user link
 * 
 * @param mixed $matches
 * @return
 */
function replace_user_link_callback($matches)
{
    if (count($matches) < 2) {
        return null;
    }
    // if
    if (!logged_user()->isMemberOfOwnerCompany()) {
        $object = Users::findOne(array('conditions' => array('`id` = ? ', $matches[1])));
    } else {
        $object = Users::findOne(array('conditions' => array('`id` = ? ', $matches[1])));
    }
    // if
    if (!$object instanceof User) {
        return '<del>' . lang('invalid reference') . '</del>';
    } else {
        return '<a href="' . $object->getCardUrl() . '">' . $object->getObjectName() . '</a>';
    }
    // if
}
开发者ID:bahmany,项目名称:PythonPurePaperless,代码行数:25,代码来源:init.php

示例9: isUserSubcomision

 public static function isUserSubcomision($id)
 {
     if (Users::findOne(['dni' => $id, 'privilegio' => 2])) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:emiherber,项目名称:sgdcae,代码行数:8,代码来源:User.php

示例10: do_share

 function do_share()
 {
     $share_data = array_var($_POST, 'share_data');
     if (is_array($share_data)) {
         $obj = get_object_by_manager_and_id(array_var($share_data, 'object_id'), array_var($share_data, 'object_manager'));
         $emails = array_var($_POST, 'emails');
         $companies = array_var($_POST, 'companiesId');
         if (!is_array($emails) || !count($emails)) {
             flash_error(lang('must specify recipients'));
             ajx_current("empty");
             return;
         }
         $people = array();
         foreach ($emails as $k => $email) {
             // Retrieve users to notify
             $lt_pos = strpos_utf($email, '<');
             if ($lt_pos !== FALSE) {
                 // only email address
                 $email = substr_utf($email, $lt_pos + 1);
                 $email = str_replace('>', '', $email);
             }
             if (trim($email) != '') {
                 $user = Users::findOne(array('conditions' => "`email` = '" . $email . "'"));
                 if (!$user instanceof User) {
                     // User not exists -> create one with minimum permissions
                     try {
                         DB::beginWork();
                         $user = $this->createMinimumUser($email, $companies[$k]);
                         DB::commit();
                     } catch (Exception $e) {
                         DB::rollback();
                     }
                 }
                 if ($user instanceof User) {
                     $people[] = $user;
                     $canWrite = array_var($share_data, 'allow_edit');
                     if ($canWrite && !$obj->canEdit($user) || !$obj->canView($user)) {
                         $this->setObjUserPermission($user, $obj, $canWrite);
                     }
                     $this->saveSharedObject($obj, $user);
                 }
             }
         }
         Notifier::shareObject($obj, $people);
         flash_success(lang("success sharing object"));
         ajx_current("back");
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:48,代码来源:ObjectController.class.php

示例11: edit_form

 /**
  * Retrieves the currently authenticated user from the 
  * database and displays the form for editing their information.
  */
 public static function edit_form()
 {
     $user = Users::findOne($_SESSION['user']);
     View::make('user/edit.html', array('user' => $user));
 }
开发者ID:nadeka,项目名称:pizzataivas,代码行数:9,代码来源:users_controller.php

示例12: findByUsername

 /**
  * Finds user by username
  *
  * @param  string      $username
  * @return static|null
  */
 public static function findByUsername($username)
 {
     $users = new Users();
     return $users->findOne(['email' => $username]);
 }
开发者ID:damisadam,项目名称:FMS,代码行数:11,代码来源:User.php


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