本文整理汇总了PHP中Users::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::count方法的具体用法?PHP Users::count怎么用?PHP Users::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::count方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->order = 'cTime DESC';
//$criteria->select = 'id,title';
$model = new Users();
$count = $model->count($criteria);
$pager = new CPagination($count);
$pager->pageSize = 100;
$pager->applyLimit($criteria);
$posts = $model->findAll($criteria);
$this->render('index', array('pages' => $pager, 'posts' => $posts));
}
示例2: getUsersCount
/**
* Return number of users in company
*
* @param void
* @return null
*/
function getUsersCount()
{
$company_id = $this->getId();
return Users::count("company_id LIKE {$company_id}");
}
示例3: function
});
/**
* Get stats
*/
$app->get('/stats', function () use($response) {
// $it = new ImagesTags();
$user = new Users();
$user_id = $user->getFbId();
$userTags = 0;
if (isset($user_id)) {
$userTags = ImagesTags::count(['conditions' => 'user_id = ' . $user_id]);
}
$rowcount = ImagesTags::count(['distinct' => 'image_id', 'conditions' => 'confidence is null']);
$imagesCount = Images::count();
$tags = ImagesTags::count(['distinct' => 'tag_id', 'conditions' => 'confidence is null']);
$users = Users::count();
// $latestTag = ImagesTags::findFirst(['orderBy' => 'created DESC', 'conditions' => 'confidence is null', 'limit' => 1])->getTags();
$response->setJsonContent(['imagesWithTags' => $rowcount, 'images' => $imagesCount, 'tags' => $tags, 'userTags' => $userTags, 'latestTag' => 0, 'users' => $users]);
$response->send();
});
/**
* Present image list by offset and limit
*/
$app->get('/images/{offset:[0-9]+}/{limit:[0-9]+}', function ($offset, $limit) use($response) {
if ($limit > 10000) {
die('maximum limit is 10000');
}
echo json_encode(Images::find(['offset' => $offset, 'limit' => $limit])->toArray(), JSON_NUMERIC_CHECK);
});
/**
* Searching images for tags
示例4:
<?php
Output::set_title("Administration");
MainTemplate::set_subtitle("Control every aspect of the Digiplay system");
$trash = Files::get_by_id(3, "dir");
echo "\n<div class=\"row\">\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "admin/music\">\n\t\t\t<div class=\"panel panel-info\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("volume-up icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . Tracks::get_total_tracks() . "</h2>\n\t\t\t\t\t\t\t<h4>tracks</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "admin/users\">\n\t\t\t<div class=\"panel panel-success\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("user icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . Users::count() . "</h2>\n\t\t\t\t\t\t\t<h4>users</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "showplans\">\n\t\t\t<div class=\"panel panel-default\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("tasks icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . Showplans::count() . "</h2>\n\t\t\t\t\t\t\t<h4>showplans</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n</div>\n<div class=\"row\">\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "audiowalls\">\n\t\t\t<div class=\"panel panel-default\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("th icon-huge\" style=\"margin-top: -4px;") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . AudiowallSets::count() . "</h2>\n\t\t\t\t\t\t\t<h4>audiowalls</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "email\">\n\t\t\t<div class=\"panel panel-warning\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("envelope icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . Emails::count_unread() . "</h2>\n\t\t\t\t\t\t\t<h4>e-mails</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "admin/trash\">\n\t\t\t<div class=\"panel panel-danger\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("trash icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . $trash->count() . "</h2>\n\t\t\t\t\t\t\t<h4>in trash</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n</div>";
示例5: set_page_title
<?php
set_page_title(lang('members'));
if (User::canAdd(logged_user(), owner_company())) {
add_page_action(lang('add user'), owner_company()->getAddUserUrl(), 'ico-add', null, null, true);
}
// if
?>
<div class="adminUsersList" style="height:100%;background-color:white">
<div class="adminHeader">
<div class="adminTitle"><?php
echo lang('users') . (config_option('max_users') ? ' (' . Users::count() . ' / ' . config_option('max_users') . ')' : '');
?>
</div>
</div>
<div class="adminSeparator"></div>
<div class="adminMainBlock">
<?php
$show_help_option = user_config_option('show_context_help');
if ($show_help_option == 'always' || $show_help_option == 'until_close' && user_config_option('show_member_context_help', true, logged_user()->getId())) {
?>
<div id="membersPanelContextHelp" style="padding-left:7px;padding:15px;background-color:white;">
<?php
render_context_help($this, 'chelp members page', 'member');
?>
</div>
<?php
}
?>
<?php
示例6: executeAction
/**
* Contruct controller and execute specific action
*
* @access public
* @param string $controller_name
* @param string $action
* @return null
*/
static function executeAction($controller_name, $action)
{
$max_users = config_option('max_users');
if ($max_users && Users::count() > $max_users) {
echo lang("error") . ": " . lang("maximum number of users exceeded error");
return;
}
ajx_check_login();
if (isset($_GET['active_project']) && logged_user() instanceof User) {
$dont_update = false;
if (GlobalCache::isAvailable()) {
$option_value = GlobalCache::get('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $success);
if ($success) {
$dont_update = $option_value == $_GET['active_project'];
}
}
if (!$dont_update) {
set_user_config_option('lastAccessedWorkspace', $_GET['active_project'], logged_user()->getId());
if (GlobalCache::isAvailable()) {
GlobalCache::update('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $_GET['active_project']);
}
}
}
Env::useController($controller_name);
$controller_class = Env::getControllerClass($controller_name);
if (!class_exists($controller_class, false)) {
throw new ControllerDnxError($controller_name);
}
// if
$controller = new $controller_class();
if (!instance_of($controller, 'Controller')) {
throw new ControllerDnxError($controller_name);
}
// if
if (is_ajax_request()) {
// if request is an ajax request return a json response
// execute the action
$controller->setAutoRender(false);
$controller->execute($action);
// fill the response
$response = AjaxResponse::instance();
if (!$response->hasCurrent()) {
// set the current content
$response->setCurrentContent("html", $controller->getContent(), page_actions(), ajx_get_panel());
}
$response->setEvents(evt_pop());
$error = flash_pop('error');
$success = flash_pop('success');
if (!is_null($error)) {
$response->setError(1, clean($error));
} else {
if (!is_null($success)) {
$response->setError(0, clean($success));
}
}
// display the object as json
tpl_assign("object", $response);
$content = tpl_fetch(Env::getTemplatePath("json"));
tpl_assign("content_for_layout", $content);
TimeIt::start("Transfer");
if (is_iframe_request()) {
tpl_display(Env::getLayoutPath("iframe"));
} else {
tpl_display(Env::getLayoutPath("json"));
}
TimeIt::stop();
} else {
return $controller->execute($action);
}
}
示例7: countExternalUsers
function countExternalUsers()
{
return Users::count('`company_id` IN (SELECT `id` FROM `' . TABLE_PREFIX . 'companies` WHERE `client_of_id` <> 0)');
}
示例8: save
/**
* Save
*
*/
function save()
{
if ($this->isNew()) {
$max_users = config_option('max_users');
if ($max_users && Users::count() >= $max_users) {
throw new Exception(lang("maximum number of users reached error"));
}
}
parent::save();
// update logged_user info in global cache
if (logged_user() instanceof User && $this->getId() == logged_user()->getId() && GlobalCache::isAvailable()) {
GlobalCache::update('logged_user_' . $this->getId(), $this);
}
}
示例9: countAdministrators
/**
* Return number of administrators
*
* @param void
* @return integer
*/
function countAdministrators()
{
$admin_role_ids = array();
$system_roles = Roles::findSystemRoles();
foreach ($system_roles as $system_role) {
if ($system_role->isAdministrator()) {
$admin_role_ids[] = $system_role->getId();
}
// if
}
// foreach
return count($admin_role_ids) > 0 ? Users::count(array("role_id IN (?)", $admin_role_ids)) : 0;
}
示例10: countUsers
/**
* Return number of company users
*
* @access public
* @param void
* @return integer
*/
function countUsers()
{
return Users::count('`company_id` = ' . DB::escape($this->getId()));
}
示例11: add
/**
* Add user
*
* @access public
* @param void
* @return null
*/
function add()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$max_users = config_option('max_users');
if ($max_users && Users::count() >= $max_users) {
flash_error(lang('maximum number of users reached error'));
ajx_current("empty");
return;
}
$this->setTemplate('add_user');
$company = Companies::findById(get_id('company_id'));
if (!$company instanceof Company) {
$company = owner_company();
}
// if
if (!User::canAdd(logged_user(), $company)) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
$user = new User();
$user_data = array_var($_POST, 'user');
if (!is_array($user_data)) {
//if it is a new user
$contact_id = get_id('contact_id');
$contact = Contacts::findById($contact_id);
if ($contact instanceof Contact) {
//if it will be created from a contact
$user_data = array('username' => $this->generateUserNameFromContact($contact), 'display_name' => $contact->getFirstname() . $contact->getLastname(), 'email' => $contact->getEmail(), 'contact_id' => $contact->getId(), 'password_generator' => 'random', 'company_id' => $company->getId(), 'timezone' => $contact->getTimezone(), 'create_contact' => false, 'type' => 'normal', 'can_manage_time' => true);
// array
} else {
// if it is new, and created from admin interface
$user_data = array('password_generator' => 'random', 'company_id' => $company->getId(), 'timezone' => $company->getTimezone(), 'create_contact' => true, 'send_email_notification' => true, 'type' => 'normal', 'can_manage_time' => true);
// array
}
}
// if
$permissions = ProjectUsers::getNameTextArray();
tpl_assign('user', $user);
tpl_assign('company', $company);
tpl_assign('permissions', $permissions);
tpl_assign('user_data', $user_data);
tpl_assign('billing_categories', BillingCategories::findAll());
if (is_array(array_var($_POST, 'user'))) {
if (!array_var($user_data, 'createPersonalProject')) {
$user_data['personal_project'] = 0;
}
try {
DB::beginWork();
$user = $this->createUser($user_data, array_var($_POST, 'permissions'));
$object_controller = new ObjectController();
$object_controller->add_custom_properties($user);
DB::commit();
flash_success(lang('success add user', $user->getDisplayName()));
ajx_current("back");
} catch (Exception $e) {
DB::rollback();
ajx_current("empty");
flash_error($e->getMessage());
}
// try
}
// if
}