当前位置: 首页>>代码示例>>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;未经允许,请勿转载。