當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::fetch方法代碼示例

本文整理匯總了PHP中User::fetch方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::fetch方法的具體用法?PHP User::fetch怎麽用?PHP User::fetch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在User的用法示例。


在下文中一共展示了User::fetch方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setAdmin

 /**
  * @description Set the an user as administrator.
  * @param mail Mail of the user.
  */
 public function setAdmin($mail)
 {
     $this->output->writeln(sprintf('Set user <info>%s</info> as Administrator', $mail));
     $admin_role = Role::get(1);
     if (empty($admin_role)) {
         $this->output->writeln('No Administrator role is in the database!');
         return FALSE;
     }
     $user = new User();
     $user->mail = $mail;
     $user->fetch('mail');
     if (empty($user->getId())) {
         $this->output->writeln(sprintf('User with the mail address <info>%s</info> not found in in the database!', $mail));
         return FALSE;
     }
     $ur = new UserRole();
     $ur->user = $user;
     $ur->role = $admin_role;
     if (!$ur->save()) {
         $this->output->writeln('Unable to associate the administrator role!');
         $this->output->writeln(print_r($ur->getErrors(), TRUE));
         return FALSE;
     }
     $this->output->writeln('User associated!');
     return TRUE;
 }
開發者ID:mermetbt,項目名稱:biome,代碼行數:30,代碼來源:RightsCommand.php

示例2: check_authentication

/**
 *  Check authentication array and set error, errorcode, errorlabel
 *  @param      authentication      Array
 *  @param      error
 *  @param      errorcode
 *  @param      errorlabel
 */
function check_authentication($authentication,&$error,&$errorcode,&$errorlabel)
{
    global $db,$conf,$langs;

    $fuser=new User($db);

    if (! $error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY))
    {
        $error++;
        $errorcode='BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel='Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
    }
    if (! $error)
    {
        $result=$fuser->fetch('',$authentication['login'],'',0);
        if ($result <= 0) $error++;

        // TODO Check password

        if ($error)
        {
            $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password';
        }
    }
    if (! $error && ! empty($authentication['entity']) && ! is_numeric($authentication['entity']))
    {
        $error++;
        $errorcode='BAD_PARAMETERS'; $errorlabel="Parameter entity must be empty (or a numeric with id of instance if multicompany module is used).";
    }

    return $fuser;
}
開發者ID:remyyounes,項目名稱:dolibarr,代碼行數:38,代碼來源:ws.lib.php

示例3: view_user

/**
 * view_user 
 * 
 * @param mixed $id the unique identifier
 *
 * @access public
 * @return string
 */
function view_user($id)
{
    $user = User::fetch($id);
    if (!$user) {
        throw new NotFoundException();
    }
    return render('user_view.tpl', compact('user'));
}
開發者ID:jouvent,項目名稱:Genitura,代碼行數:16,代碼來源:controllers.php

示例4: check_authentication

/**
 *  Check authentication array and set error, errorcode, errorlabel
 *
 *  @param	array	$authentication     Array with authentication informations ('login'=>,'password'=>,'entity'=>,'dolibarrkey'=>)
 *  @param 	int		&$error				Number of errors
 *  @param  string	&$errorcode			Error string code
 *  @param  string	&$errorlabel		Error string label
 *  @return User						Return user object identified by login/pass/entity into authentication array
 */
function check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
{
    global $db, $conf, $langs;
    global $dolibarr_main_authentication, $dolibarr_auto_user;
    $fuser = new User($db);
    if (!$error && $authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY) {
        $error++;
        $errorcode = 'BAD_VALUE_FOR_SECURITY_KEY';
        $errorlabel = 'Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
    }
    if (!$error && !empty($authentication['entity']) && !is_numeric($authentication['entity'])) {
        $error++;
        $errorcode = 'BAD_PARAMETERS';
        $errorlabel = "Parameter entity must be empty (or filled with numeric id of instance if multicompany module is used).";
    }
    if (!$error) {
        $result = $fuser->fetch('', $authentication['login'], '', 0);
        if ($result < 0) {
            $error++;
            $errorcode = 'ERROR_FETCH_USER';
            $errorlabel = 'A technical error occurs during fetch of user';
        } else {
            if ($result == 0) {
                $error++;
                $errorcode = 'BAD_CREDENTIALS';
                $errorlabel = 'Bad value for login or password';
            }
        }
        if (!$error && $fuser->statut == 0) {
            $error++;
            $errorcode = 'ERROR_USER_DISABLED';
            $errorlabel = 'This user has been locked or disabled';
        }
        // Validation of login
        if (!$error) {
            $fuser->getrights();
            // Load permission of user
            // Authentication mode
            if (empty($dolibarr_main_authentication)) {
                $dolibarr_main_authentication = 'http,dolibarr';
            }
            // Authentication mode: forceuser
            if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) {
                $dolibarr_auto_user = 'auto';
            }
            // Set authmode
            $authmode = explode(',', $dolibarr_main_authentication);
            include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
            $login = checkLoginPassEntity($authentication['login'], $authentication['password'], $authentication['entity'], $authmode);
            if (empty($login)) {
                $error++;
                $errorcode = 'BAD_CREDENTIALS';
                $errorlabel = 'Bad value for login or password';
            }
        }
    }
    return $fuser;
}
開發者ID:nrjacker4,項目名稱:crm-php,代碼行數:67,代碼來源:ws.lib.php

示例5: topMenu

 function topMenu()
 {
     $menu = array();
     if (Permission::checkPermission(pow(2, 2))) {
         $user = new User((int) $_SESSION['user_id']);
         $user->fetch();
         $menu[] = array('name' => $user->getNickname(), 'href' => 'user.php?user_id=' . $user->getUserId());
     }
     return $menu;
 }
開發者ID:wAmpIre,項目名稱:netmon,代碼行數:10,代碼來源:menus.class.php

示例6: ideaboxGetUserNom

function ideaboxGetUserNom($id)
{
    global $db, $langs;
    if (isset($id) && $id > 0) {
        $user = new User($db);
        $user->fetch($id);
        return $user->login;
    } else {
        return false;
    }
}
開發者ID:atm-arnaud,項目名稱:dolibarr_module_ideabox,代碼行數:11,代碼來源:ideabox.lib.php

示例7: getUser

 static function getUser(&$PDOdb, $fk_category)
 {
     global $conf, $db;
     $Tab = $PDOdb->ExecuteAsArray("SELECT fk_user FROM " . MAIN_DB_PREFIX . "commercial_category WHERE fk_category=" . $fk_category);
     $TUser = array();
     foreach ($Tab as &$row) {
         $u = new User($db);
         if ($u->fetch($row->fk_user) > 0) {
             $TUser[] = $u;
         }
     }
     return $TUser;
 }
開發者ID:ATM-Consulting,項目名稱:dolibarr_module_commercialbycategory,代碼行數:13,代碼來源:commercialcategory.class.php

示例8: logout

 function logout()
 {
     $model_user = new User($this->dbconn, $_SESSION['user']->id);
     $model_user->fetch();
     $model_user->logout();
     if (isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])) {
         setcookie("cookname", "", time() - 2592000, "/");
         setcookie("cookpass", "", time() - 2592000, "/");
         unset($_COOKIE['cookname']);
         unset($_COOKIE['cookpass']);
     }
     header('Location: index.php');
     exit;
 }
開發者ID:arimano,項目名稱:plyloedit,代碼行數:14,代碼來源:HeaderController.php

示例9: loadCurrentUser

 /**
  * Връща модел за текущия потребител
  * 
  * Ако има $_SESSION['user_id'] се връща модел,
  * с това което е успял да зареди, в противен случай
  * се връща false
  * 
  * @return mixed: User|boolean
  */
 static function loadCurrentUser()
 {
     if (empty($_SESSION['user_id'])) {
         return false;
     }
     if ($_SESSION['user_serialized']) {
         $_SESSION['user'] = unserialize($_SESSION['user_serialized']);
         $_SESSION['user']->dbconn = DBConn::getInstance()->conn;
     } else {
         $model_user = new User(DBConn::getInstance()->conn, $_SESSION['user_id']);
         $model_user->fetch();
         $_SESSION['user'] = $model_user;
         $_SESSION['user_serialized'] = serialize($model_user);
     }
     return $_SESSION['user'];
 }
開發者ID:arimano,項目名稱:plyloedit,代碼行數:25,代碼來源:user.class.php

示例10: index

 function index($id)
 {
     if ($id) {
         $user = new User($this->dbconn, $id);
         if ($user->fetch()) {
             $user->getTrees();
             $this->smarty->Assign('user', $user);
             $this->display('User/profile.tpl');
         } else {
             $_SESSION['system_error'] = _("Потребител с такова ID не съществува");
             $this->display('Main/main.tpl');
         }
     } else {
         $this->showList();
     }
 }
開發者ID:arimano,項目名稱:plyloedit,代碼行數:16,代碼來源:UserController.php

示例11: login

function login()
{
    include "user.php";
    $obj = new User();
    $uname = $_REQUEST['uname'];
    $pword = $_REQUEST['pword'];
    if (!$obj->getUser($uname, $pword)) {
        echo '{"result":0,"message": "failed to access user information"}';
    } else {
        $row = $obj->fetch();
        $_SESSION['userid'] = $row['id'];
        $_SESSION['username'] = $row['username'];
        $_SESSION['password'] = $row['password'];
        $_SESSION['permission'] = $row['permission'];
        getUserDetails();
    }
}
開發者ID:samsali,項目名稱:SE-GROUP13,代碼行數:17,代碼來源:task_controller.php

示例12: __isAllowed

 /**
  * Check access
  *
  * @return bool
  * @throws RestException
  */
 public function __isAllowed()
 {
     global $db;
     $stored_key = '';
     $userClass = Defaults::$userIdentifierClass;
     if (isset($_GET['api_key'])) {
         $sql = "SELECT u.login, u.datec, u.api_key, ";
         $sql .= " u.tms as date_modification, u.entity";
         $sql .= " FROM " . MAIN_DB_PREFIX . "user as u";
         $sql .= " WHERE u.api_key = '" . $db->escape($_GET['api_key']) . "'";
         $result = $db->query($sql);
         if ($result) {
             if ($db->num_rows($result)) {
                 $obj = $db->fetch_object($result);
                 $login = $obj->login;
                 $stored_key = $obj->api_key;
             }
         } else {
             throw new RestException(503, 'Error when fetching user api_key :' . $db->error_msg);
         }
         if ($stored_key != $_GET['api_key']) {
             $userClass::setCacheIdentifier($_GET['api_key']);
             return false;
         }
         $fuser = new User($db);
         if (!$fuser->fetch('', $login)) {
             throw new RestException(503, 'Error when fetching user :' . $fuser->error);
         }
         $fuser->getrights();
         static::$user = $fuser;
         if ($fuser->societe_id) {
             static::$role = 'external';
         }
         if ($fuser->admin) {
             static::$role = 'admin';
         }
     } else {
         throw new RestException(401, "Failed to login to API. No parameter 'api_key' provided");
         //dol_syslog("Failed to login to API. No parameter key provided", LOG_DEBUG);
         //return false;
     }
     $userClass::setCacheIdentifier(static::$role);
     Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess';
     return in_array(static::$role, (array) static::$requires) || static::$role == 'admin';
 }
開發者ID:Samara94,項目名稱:dolibarr,代碼行數:51,代碼來源:api_access.class.php

示例13: updateUserUrls

function updateUserUrls()
{
    printfnq("Updating user URLs...\n");
    // XXX: only update user URLs where out-of-date
    $user = new User();
    if ($user->find()) {
        while ($user->fetch()) {
            printfv("Updating user {$user->nickname}...");
            try {
                $profile = $user->getProfile();
                updateProfileUrl($profile);
            } catch (Exception $e) {
                echo "Error updating URLs: " . $e->getMessage();
            }
            printfv("DONE.");
        }
    }
}
開發者ID:bashrc,項目名稱:gnusocial-debian,代碼行數:18,代碼來源:updateurls.php

示例14: _get_projet_cdp

function _get_projet_cdp()
{
    global $db;
    $TData = array();
    $sql = 'SELECT COUNT(p.rowid) AS nombre, ec.fk_socpeople AS user FROM ' . MAIN_DB_PREFIX . 'projet p ';
    $sql .= 'INNER JOIN ' . MAIN_DB_PREFIX . 'element_contact ec ON ec.element_id=p.rowid ';
    $sql .= 'WHERE ec.fk_c_type_contact = 160 AND p.fk_statut=1 ';
    $sql .= 'GROUP BY ec.fk_socpeople ';
    $resql = $db->query($sql);
    if ($resql) {
        while ($line = $db->fetch_object($resql)) {
            $user = new User($db);
            $user->fetch($line->user);
            $TData[] = array("nom" => $user->firstname . ' ' . $user->lastname, "nombre" => $line->nombre);
        }
    }
    return $TData;
}
開發者ID:ATM-Consulting,項目名稱:dolibarr_module_scrumboard,代碼行數:18,代碼來源:nb_proj_cdp.php

示例15: handle

 /**
  * Handle the site
  * 
  * @param mixed $object
  * @return boolean true on success, false on failure
  */
 function handle($object)
 {
     $qm = QueueManager::get();
     try {
         // Enqueue a summary for all users
         $user = new User();
         $user->find();
         while ($user->fetch()) {
             try {
                 $qm->enqueue($user->id, 'usersum');
             } catch (Exception $e) {
                 common_log(LOG_WARNING, $e->getMessage());
                 continue;
             }
         }
     } catch (Exception $e) {
         common_log(LOG_WARNING, $e->getMessage());
     }
     return true;
 }
開發者ID:microcosmx,項目名稱:experiments,代碼行數:26,代碼來源:siteemailsummaryhandler.php


注:本文中的User::fetch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。