本文整理汇总了PHP中User::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP User::factory方法的具体用法?PHP User::factory怎么用?PHP User::factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gallery_upload
public function gallery_upload($cid, $uid)
{
//if (!$this->loginmanager->is_logged_in())
//show_error('You are not logged in!', 403);
$content = Content::factory((int) $cid);
$u = User::factory((int) $uid);
$config['upload_path'] = "iu-assets/galleries/";
$config['allowed_types'] = 'png|jpg|jpeg|jpe|gif';
$this->load->library('upload', $config);
//file_put_contents('uploadify', json_encode($_FILES));
if (!$this->upload->do_upload("Filedata")) {
$error = $this->upload->display_errors();
// do stuff
show_error('Couldn\'t upload!', 500);
} else {
$data = $this->upload->data();
$gi = new GalleryItem();
$gi->image = $config['upload_path'] . $data['file_name'];
$gi->order = 0;
$gi->save(array($content, $content->page->get()->user->get()));
$content->updated = time();
$content->save();
}
echo 'OK!';
}
示例2: indexAction
public function indexAction()
{
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
throw new Exception("Please login");
}
$user = User::factory($auth->getIdentity());
if (!$user->isAdmin()) {
throw new Exception("You must be an admin to view this page.");
}
$this->_helper->viewRenderer->setNoRender();
Zend_Loader::loadClass("UserModel");
$usermodel = new UserModel();
$users = $usermodel->getUserList();
foreach ($users as $username) {
$user = User::factory($username);
$memcount = $usermodel->getMemberCount($user);
for ($i = 0; $i < $memcount; $i++) {
$member = $usermodel->getMember($user, $i);
if (!empty($member->email)) {
echo "{$member->email}, ";
}
}
}
}
示例3: message
public function message()
{
if (empty($this->user_id)) {
return $this->ip_addr . ' ' . $this->message;
} else {
return User::factory($this->user_id)->name . ' ' . $this->message();
}
}
示例4: testUsersFactory
public function testUsersFactory()
{
Client::relateIQ(GlobalVar::KEY, GlobalVar::SECRET);
$data = ['id' => '538530d2e4b00530d85ae1bf'];
$other = User::factory($data);
$this->assertInstanceOf('User', $other);
$this->assertEquals($data['id'], $other->id());
}
示例5: __construct
public function __construct()
{
parent::__construct();
//$this->output->enable_profiler(TRUE);
//check if config file is empty or it's not empty but script is not installed
if ((is_db_conf_empty() || !is_installed()) && !defined('CS_EXTERNAL')) {
redirect("setup/index");
}
//load database, datamapper and login manager
$this->load->database();
$this->load->library('datamapper');
$this->load->library('translate');
$this->load->library('loginmanager');
//hack for datamapper prefix
DataMapper::$config['prefix'] = $this->db->dbprefix;
//set web site name in title
$this->templatemanager->set_title(Setting::value('website_title', CS_PRODUCT_NAME));
//test if should save uri
$should = true;
if ($this instanceof Process) {
$uri = $path = trim($this->uri->uri_string());
$file = new File();
$file->path = $path;
$mime = $file->mime_type();
if ($mime !== 'text/html') {
$should = false;
}
}
//set current url for auth controller to know where to redirect
if (!$this instanceof Auth && !$this instanceof JS && !$this->is_ajax_request() && $should) {
$this->loginmanager->set_redirect(current_url());
}
//set time zone
date_default_timezone_set(Setting::value('default_time_zone', 'Europe/Belgrade'));
//set language
$sess_lang = $this->session->userdata('lang');
if (!empty($sess_lang)) {
if (is_numeric($sess_lang)) {
$lang = Language::factory()->get_by_id((int) $sess_lang)->name;
} else {
$lang = $sess_lang;
}
} else {
$lang = Setting::value('default_language', 'English');
}
$this->translate->set_language($lang);
//fetch user from the database if logged in
if ($this->loginmanager->is_logged_in()) {
$this->user = User::factory($this->loginmanager->user->id);
$this->templatemanager->assign('user', $this->user);
}
$this->templatemanager->set_template_name($this->in_admin() ? "administration" : "");
if ($this->in_admin() && isset($_GET['iu-popup'])) {
$this->templatemanager->popup();
}
}
示例6: preDispatch
public function preDispatch()
{
$this->contestmodel = new ContestModel();
$this->state = $this->contestmodel->getContestState(webconfig::getContestId());
if ($this->state != "ongoing") {
$user = User::factory(Zend_Auth::getInstance()->getIdentity());
if (!$user || !$user->isAdmin()) {
$this->_forward("{$this->state}", "error", NULL, array());
}
}
}
示例7: __construct
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('datamapper');
$this->load->library('loginmanager');
//hack for datamapper prefix
DataMapper::$config['prefix'] = $this->db->dbprefix;
if ($this->loginmanager->is_logged_in()) {
$this->user = User::factory($this->loginmanager->user->id);
}
}
示例8: testUploadHashWorks
/**
* @dataProvider provider
*/
public function testUploadHashWorks ($user, $prob, $lang, $source, $owner, $score)
{
config::$enable_hash_test = true;
$a = UploadSubmission::upload ($user, $prob, $lang, $source, $owner);
$b = UploadSubmission::upload ($user, $prob, $lang, $source, $owner);
$user = User::factory ($user);
if (!$user->isAdmin())
$this->assertEquals (-1, $b);
else
$this->assertGreaterThan (0, $b);
}
示例9: indexAction
public function indexAction()
{
if (webconfig::getContest()->isQueuePrivate()) {
$user = User::factory(Zend_Auth::getInstance()->getIdentity());
if (!$user || !$user->isAdmin()) {
$this->_forward("privacy", "error", NULL, array());
}
}
$user = $this->_request->get("user");
$prob = $this->_request->get("prob");
$this->view->user = $user;
$this->view->prob = $prob;
Zend_Loader::loadClass("RanklistModel");
$ranklist = new RanklistModel();
$this->view->ranks = $ranklist->getRanks($user, $prob, webconfig::getContestId());
}
示例10: indexAction
public function indexAction()
{
$offset = (int) $this->_request->get("offset");
$limit = (int) $this->_request->get("limit");
if (empty($offset)) {
$offset = 0;
}
if (empty($limit)) {
$limit = 100;
}
$user = $this->_request->get("user");
$uid = $this->_request->get("uid");
$problem = $this->_request->get("problem");
$state = $this->_request->get("state");
if (webconfig::getContest()->isQueuePrivate()) {
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
$this->_forward("login", "error", NULL, array());
} else {
$userobj = User::factory($auth->getIdentity());
if (!$userobj->isAdmin() and !isset($uid)) {
$this->_forward("privacy", "error", NULL, array());
}
}
}
Zend_Loader::loadClass("Zend_Paginator");
Zend_Loader::loadClass("Zend_Paginator_Adapter_DbSelect");
$db = contestDB::get_zend_db();
$query = $db->select()->from('submissionqueue')->join("users", "submissionqueue.uid = users.uid")->where("owner = ?", webconfig::getContestId())->order("id desc");
if (!empty($user)) {
$query = $query->where("users.username = ?", $user);
}
if (!empty($uid)) {
$query = $query->where("users.uid = ?", $uid);
}
if (!empty($problem)) {
$query = $query->where("submissionqueue.problemid = ?", $problem);
}
if (!empty($state)) {
$query = $query->where("submissionqueue.state = ?", $state);
}
$adapter = new Zend_Paginator_Adapter_DbSelect($query);
$this->view->paginator = new Zend_Paginator($adapter);
$this->view->paginator->setCurrentPageNumber($this->_getParam('page'));
$this->view->paginator->setItemCountPerPage(50);
}
示例11: getUsersList
public function getUsersList()
{
$tblName = Privileges::$privilegesTable;
$sql = "SELECT `User`, `Host`, `Password` FROM {$tblName} ORDER BY `User`, `Host`";
if (false == $this->db->query($sql)) {
return array();
}
$users = array();
while ($row = $this->db->fetchRow()) {
$user = User::factory($this->legacy);
$user->userName = $row['User'];
$user->host = $row['Host'];
$user->password = $row['Password'];
$users[] = $user;
}
return $users;
}
示例12: indexAction
public function indexAction()
{
/* make sure I'm an admin */
$curuser = Zend_Auth::getInstance()->getIdentity();
if (empty($curuser) || !User::factory($curuser)->isAdmin()) {
$this->_forward("illegal", "error");
return;
}
$user = $this->_request->get("user");
$authAdapter = new SuAuthAdapter($user);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$this->_redirect("/pages/home");
} else {
$this->_forward("illegal", "error");
}
}
示例13: indexAction
public function indexAction()
{
$_user = $this->_request->get("user");
if (webconfig::getContest()->isQueuePrivate()) {
$user = User::factory(Zend_Auth::getInstance()->getIdentity());
if (!$user || !$user->isAdmin()) {
$this->_forward("privacy", "error", NULL, array());
}
}
if (empty($_user)) {
$this->_redirect(webconfig::getContestRelativeBaseUrl());
}
/* fillin information from User XML data */
Zend_Loader::loadClass("UserModel");
$userm = new UserModel();
$user = $userm->getRow($_user);
$this->view->username = $user->_username;
$this->view->inst = $userm->getInstitute($user);
$this->view->name = $userm->getMember($user, 0)->name;
}
示例14: __construct
public function __construct()
{
$this->framework =& get_instance();
$this->session =& $this->framework->session;
if (empty($this->framework->session)) {
$this->framework->load->library('session');
$this->session =& $this->framework->session;
}
if ($this->session->userdata('logged_in_user') !== false) {
$usr = unserialize($this->session->userdata('logged_in_user'));
$this->user = User::factory($usr->id);
}
//log out if not remembered and is inactive for (more than) 1 hour
$remember = $this->session->userdata('remember');
$last_active = $this->session->userdata('last_activity');
$diff = time() - (int) $last_active;
$diff = $diff / 3600;
if ($this->is_logged_in() && !$remember && $diff > 1) {
$this->process_logout();
redirect($this->get_redirect());
}
}
示例15: userOwnsObj
/**
* @param $user_id
* @param $obj InterfaceOwner
* @return bool
*/
public static function userOwnsObj($user_id, $obj)
{
\OLOG\Assert::assert($obj instanceof InterfaceOwner, 'Object must implement ' . \OLOG\Auth\InterfaceOwner::class . ' interface');
$current_user_obj = User::factory($user_id);
if ($current_user_obj->getHasFullAccess()) {
return true;
}
$current_user_usertogroup_ids_arr = UserToGroup::getIdsArrForUserIdByCreatedAtDesc($user_id);
$current_user_groups_ids_arr = [];
foreach ($current_user_usertogroup_ids_arr as $usertogroup_id) {
$usertogroup_obj = UserToGroup::factory($usertogroup_id);
$current_user_groups_ids_arr[] = $usertogroup_obj->getGroupId();
}
if ($obj->getOwnerUserId() == $user_id) {
return true;
}
$obj_owner_group_id = $obj->getOwnerGroupId();
if (in_array($obj_owner_group_id, $current_user_groups_ids_arr)) {
return true;
}
return false;
}