PHP Method User::getCount, codiad Code Examples

This page contains top rated real world PHP examples of method User::getCount from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: DemoDataUtilTest.php Project: youprofit/Zurmo
0
 public function testLoad()
 {
     $this->assertEquals(2, Group::getCount());
     $this->assertEquals(0, Role::getCount());
     $this->assertEquals(0, Account::getCount());
     $this->assertEquals(0, Contact::getCount());
     $this->assertEquals(0, Opportunity::getCount());
     $this->assertEquals(0, Meeting::getCount());
     $this->assertEquals(0, Note::getCount());
     $this->assertEquals(0, Task::getCount());
     $this->assertEquals(1, User::getCount());
     $this->assertEquals(0, ProductCatalog::getCount());
     $this->assertEquals(0, ProductCategory::getCount());
     $this->assertEquals(0, ProductTemplate::getCount());
     $this->assertEquals(0, Product::getCount());
     $messageLogger = new MessageLogger();
     DemoDataUtil::unsetLoadedModules();
     DemoDataUtil::load($messageLogger, 3);
     $this->assertEquals(8, Group::getCount());
     $this->assertEquals(3, Role::getCount());
     $this->assertEquals(3, Account::getCount());
     $this->assertEquals(16, Contact::getCount());
     $this->assertEquals(6, Opportunity::getCount());
     $this->assertEquals(18, Meeting::getCount());
     $this->assertEquals(12, Note::getCount());
     $this->assertEquals(9, Task::getCount());
     $this->assertEquals(10, User::getCount());
     $this->assertEquals(1, ProductCatalog::getCount());
     $this->assertEquals(6, ProductCategory::getCount());
     $this->assertEquals(32, ProductTemplate::getCount());
     $this->assertEquals(59, Product::getCount());
 }
Example #2
Show file File: GroupsTreeListView.php Project: sandeep1027/zurmo_
0
 protected function resolveUserCountForItem(Item $item)
 {
     if ($item->name == Group::EVERYONE_GROUP_NAME) {
         return User::getCount();
     }
     return $item->{$this->getModelRelationNameForUserCount()}->count();
 }
Example #3
Show file File: UserImportTest.php Project: maruthisivaprasad/zurmo
0
 public function testSimpleUserImportWhereAllRowsSucceed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $users = User::getAll();
     $this->assertEquals(1, count($users));
     $import = new Import();
     $serializedData['importRulesType'] = 'User';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.users.tests.unit.files'));
     $this->assertEquals(11, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $defaultLanguage = Yii::app()->language;
     $localeIds = ZurmoLocale::getSelectableLocaleIds();
     $defaultLocale = $localeIds[0];
     $timezoneIdentifiers = DateTimeZone::listIdentifiers();
     $defaultTimeZone = $timezoneIdentifiers[0];
     $defaultCurrency = Yii::app()->currencyHelper->getActiveCurrencyForCurrentUser();
     $defaultCurrencyId = $defaultCurrency->id;
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'username', 'type' => 'importColumn', 'mappingRulesData' => array()), 'column_1' => array('attributeIndexOrDerivedType' => 'Password', 'type' => 'importColumn', 'mappingRulesData' => array('PasswordDefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_2' => array('attributeIndexOrDerivedType' => 'UserStatus', 'type' => 'importColumn', 'mappingRulesData' => array('UserStatusDefaultValueMappingRuleForm' => array('defaultValue' => UserStatusUtil::ACTIVE))), 'column_3' => ImportMappingUtil::makeStringColumnMappingData('firstName'), 'column_4' => ImportMappingUtil::makeStringColumnMappingData('lastName'), 'column_5' => array('attributeIndexOrDerivedType' => 'role', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_ID))), 'column_6' => array('attributeIndexOrDerivedType' => 'language', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => $defaultLanguage))), 'column_7' => array('attributeIndexOrDerivedType' => 'locale', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => $defaultLocale))), 'column_8' => array('attributeIndexOrDerivedType' => 'timeZone', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => $defaultTimeZone))), 'column_9' => array('attributeIndexOrDerivedType' => 'currency', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => $defaultCurrencyId))));
     $importRules = ImportRulesUtil::makeImportRulesByType('Users');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 10 models where created.
     $this->assertEquals(11, User::getCount());
     $activeUser = User::getByUsername('myusername7');
     $userStatus = UserStatusUtil::makeByUser($activeUser);
     $this->assertTrue($userStatus->isActive());
     $this->assertEquals($defaultLanguage, $activeUser->language);
     $this->assertEquals($defaultLocale, $activeUser->locale);
     $this->assertEquals($defaultTimeZone, $activeUser->timeZone);
     $this->assertEquals($defaultCurrency, $activeUser->currency);
     $inactiveUser = User::getByUsername('myusername8');
     $userStatus = UserStatusUtil::makeByUser($inactiveUser);
     $this->assertEquals($defaultLanguage, $inactiveUser->language);
     $this->assertEquals($defaultLocale, $inactiveUser->locale);
     $this->assertEquals($defaultTimeZone, $inactiveUser->timeZone);
     $this->assertEquals($defaultCurrency, $inactiveUser->currency);
     $this->assertFalse($userStatus->isActive());
     //Confirm 10 rows were processed as 'created'.
     $this->assertEquals(10, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
     //Confirm that 0 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 2 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
 }
Example #4
Show file File: index.php Project: execrot/mongostar
0
 *
 * @method static User[] fetchAll(array $cond = null, array $sort = null, $count = null, $offset = null, $hint = NULL)
 * @method static User|null fetchOne(array $cond = null, array $sort = null)
 * @method static User fetchObject(array $cond = null, array $sort = null)
 */
class User extends Mongostar_Model
{
}
$newUser = User::fetchObject(array('id' => null));
echo $newUser->name . "<br>";
die("lsjdlksj");
if (rand(0, 1)) {
    // User::remove();
}
$user = User::fetchOne(array('id' => '54de8e1e9cd81ebf330041bc'));
echo $user->name . "<br>";
$user->name = "User_name - " . rand(1000, 9999);
$user->save();
$user = User::fetchOne(array('id' => '54de8e1e9cd81ebf330041bc'));
echo $user->name . "<br>";
die;
$user->name = "Name: " . rand(1000, 9999);
$user->save();
echo "last name: " . $user->name . "<br/>";
$user->name = "Name-edited";
$user->save();
foreach (User::fetchAll() as $user) {
    echo $user->id . ' - ' . $user->name . "<br>";
}
echo "count: " . User::getCount() . "<br>";
Example #5
Show file File: User.php Project: youprofit/Zurmo
0
 public static function getRootUserCount()
 {
     $searchAttributeData['clauses'] = array(1 => array('attributeName' => 'isRootUser', 'operatorType' => 'equals', 'value' => true));
     $searchAttributeData['structure'] = '1';
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('User');
     $where = RedBeanModelDataProvider::makeWhere('User', $searchAttributeData, $joinTablesAdapter);
     return User::getCount($joinTablesAdapter, $where, null);
 }
Example #6
Show file File: admin_users.php Project: jedaika/Trainings
0
    function displayBody()
    {
        parent::displayBody();
        $translator = new Translator();
        $user = new User();
        $page = $_GET['page'];
        $offset = intval($page) * ITEMS_IN_PAGE;
        if (isset($_GET['search'])) {
            unset($_GET['search']);
            unset($_GET['page']);
            $search = $_GET;
        } else {
            $search = null;
        }
        $cnt = $user->getCount($search);
        if (sizeof($_GET) > 0) {
            foreach ($_GET as $key => $val) {
                $values[$key] = htmlspecialchars($val, ENT_QUOTES);
            }
            foreach ($user->roles as $key => $val) {
                if (($_GET['role_id'] & $val) > 0) {
                    $valname = 'role' . $val;
                    ${$valname} = 'checked';
                }
            }
            if ($_GET['role_id'] == 0) {
                $role0 = 'checked';
                $values['role_id'] = 0;
            }
        }
        if ($cnt > ITEMS_IN_PAGE) {
            $pagination = $this->addPaginator($cnt, $page);
        }
        echo <<<EOF
<h2  class="page-header">{$translator->Users_header} <span class="badge">{$cnt}</span></h2>
    <div class="row">
\t<div class="col-md-1">
\t<button class="btn btn-sm btn-default"  data-toggle="collapse" data-target="#filter">
\t    <span class="glyphicon glyphicon-filter"></span> {$translator->Filter}</button>
\t</div>
    </div>
    <div class="row">
        <div class="col-md-5 collapse" id="filter">
\t    <form role="form" class="form-horizontal" action="?" method="get">
\t\t<div class="form-group">
\t\t    <div class="form-group">
\t\t    <label for="name" class="control-label col-sm-3">{$translator->Name}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="name" name="name" value="{$values[name]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="email" class="control-label col-sm-3">{$translator->Email}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="email" name="email" value="{$values[email]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="company" class="control-label col-sm-3">{$translator->Company}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="company" name="company" value="{$values[company]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="phone" class="control-label col-sm-3">{$translator->Phone}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="phone" name="phone"  value="{$values[phone]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="country" class="control-label col-sm-3">{$translator->Country}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="country" name="country" value="{$values[country]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <label for="city" class="control-label col-sm-3">{$translator->City}:</label>
\t\t    <div class="col-sm-8">
\t\t    <input type="text" class="form-control" id="city" name="city" value="{$values[city]}">
\t\t    </div>
\t\t    </div>
\t\t    <div class="col-sm-offset-3">

EOF;
        foreach ($user->roles as $key => $val) {
            $valname = 'role' . $val;
            echo "\t\t    <input type=\"checkbox\" class=\"role_id\" id=\"{$valname}\" value=\"{$val}\" " . ${$valname} . ">\n\t\t    <label for=\"{$valname}\">" . User::RolesAsString($val) . "</label>" . NL;
        }
        echo <<<EOF
\t\t    <input class="sr-only" id="role_id" name="role_id" value="{$values[role_id]}">
\t\t    <input class="sr-only" name="search" value="1">
\t\t    </div>
\t\t    <div class="form-group">
\t\t    <div class="col-sm-offset-3 col-md-10">
\t\t    <button type="submit" class="btn btn-sm btn-default">{$translator->Apply}</button>
\t\t    </div>
\t\t    </div>
\t\t</div>
\t    </form>
\t</div>
    </div>
{$pagination}
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>#</th>
                  <th>{$translator->Name}</th>
                  <th>{$translator->Roles}</th>
                  <th>{$translator->Email}</th>
                  <th>{$translator->Phone}</th>
                  <th>{$translator->Company}</th>
                  <th>{$translator->Place}</th>
                </tr>
              </thead>
              <tbody>

EOF;
        $enum = $user->enumerate($search, $offset, ITEMS_IN_PAGE, 'users.last_name,users.first_name');
        if (is_object($enum)) {
            $i = 1 + $offset;
            foreach ($enum as $key => $data) {
                if ($data['active'] == 'f') {
                    $active = " class=\"not-active\"";
                } else {
                    $active = "";
                }
                echo "                <tr>\n                  <td>{$i}</td>\n                  <td" . $active . ">{$data[name]}</td>\n                  <td>" . User::RolesAsString($data['role_id']) . "</td>\n                  <td>{$data[email]}</td>\n                  <td>{$data[phone]}</td>\n                  <td>{$data[company]} <small>{$data[position]}</small></td>\n                  <td>{$data[country]} <small>{$data[city]}</small></td>\n                  <td><a href=\"/admin_user/edit/{$data[id]}\" title=\"{$translator->edit}\"><span class=\"glyphicon glyphicon-user\"></span></a></td>\n                  <td><a href=\"/admin_user/delete/{$data[id]}\" title=\"{$translator->del}\" onClick=\"return confirm('{$translator->AreYouSure}');\"><span class=\"glyphicon glyphicon-trash\"></span></a></td>\n                </tr>\n";
                $i++;
            }
        }
        echo <<<EOF
\t    </table>
\t</div>

EOF;
    }
Example #7
Show file File: UserTest.php Project: maruthisivaprasad/zurmo
0
 /**
  * @depends testCreateUserWithRelatedUser
  */
 public function testSavingExistingUserDoesntCreateRelatedBlankUsers()
 {
     $userCount = User::getCount();
     $dick = User::getByUsername('dick');
     $this->assertTrue($dick->save());
     $this->assertEquals($userCount, User::getCount());
 }
Example #8
Show file File: ex5-23.php Project: ganganimaulik/robinNixon4thEd
0
<?php

class User
{
    static $count = 0;
    public function getCount()
    {
        return self::$count;
    }
}
$maulik = new User();
//	echo 'test a : '. $maulik->count; brings notice undefined property.
echo $maulik->getCount();
echo User::$count;
Example #9
Show file File: state.php Project: th1209/php_design_pattern
0
        throw new RuntimeException('Clone is not allowed against ' . get_class($this));
    }
}
/**
 * Client
 */
session_start();
$context = isset($_SESSION['context']) ? $_SESSION['context'] : null;
if (is_null($context)) {
    $context = new User('ほげ');
}
$mode = isset($_GET['mode']) ? $_GET['mode'] : '';
switch ($mode) {
    case 'state':
        echo '<p style="color: #aa0000">状態を遷移します</p>';
        $context->switchState();
        break;
    case 'inc':
        echo '<p style="color: #008800">カウントアップします</p>';
        $context->incrementCount();
        break;
    case 'reset':
        echo '<p style="color: #008800">カウントをリセットします</p>';
        $context->resetCount();
        break;
}
$_SESSION['context'] = $context;
echo 'ようこそ、' . $context->getUserName() . 'さん<br>';
echo '現在、ログインして' . ($context->isAuthenticated() ? 'います' : 'いません') . '<br>';
echo '現在のカウント:' . $context->getCount() . '<br>';
echo $context->getMenu() . '<br>';
Example #10
Show file File: Group.php Project: maruthisivaprasad/zurmo
0
 /**
  * Return number of users in group except system users
  * @return int
  */
 public function getUserCountExceptSystemUsers()
 {
     $searchAttributeData['clauses'] = array(1 => array('attributeName' => 'isSystemUser', 'operatorType' => 'equals', 'value' => 0), 2 => array('attributeName' => 'isSystemUser', 'operatorType' => 'isNull', 'value' => null));
     if ($this->name == Group::EVERYONE_GROUP_NAME) {
         $searchAttributeData['structure'] = '1 or 2';
     } else {
         $searchAttributeData['clauses'][3] = array('attributeName' => 'groups', 'relatedAttributeName' => 'id', 'operatorType' => 'equals', 'value' => $this->id);
         $searchAttributeData['structure'] = '(1 or 2) and 3';
     }
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('User');
     $where = RedBeanModelDataProvider::makeWhere('User', $searchAttributeData, $joinTablesAdapter);
     return User::getCount($joinTablesAdapter, $where);
 }
Example #11
Show file File: MissionsUserWalkthroughTest.php Project: maruthisivaprasad/zurmo
0
 /**
  * @depends testSuperUserAllSimpleControllerActions
  */
 public function testSuperUserCreateMission()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $steven = User::getByUsername('steven');
     $sally = User::getByUsername('sally');
     $mary = User::getByUsername('mary');
     $missions = Mission::getAll();
     $this->assertEquals(0, count($missions));
     $this->setPostArray(array('Mission' => array('description' => 'TestDescription', 'reward' => 'Reward')));
     $this->runControllerWithRedirectExceptionAndGetContent('missions/default/create');
     //Confirm mission saved.
     $missions = Mission::getAll();
     $this->assertEquals(1, count($missions));
     $this->assertEquals('TestDescription', $missions[0]->description);
     $this->assertEquals(Mission::STATUS_AVAILABLE, $missions[0]->status);
     //Confirm everyone has read/write
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($missions[0]);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertTrue(isset($readWritePermitables[$everyoneGroup->getClassId('Permitable')]));
     //Confirm email was sent
     $this->assertEquals(2, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailMessages = EmailMessage::getAll();
     //Dont send message to super neither to steven (he has turned off)
     $recipents = array();
     $recipents[] = strval($emailMessages[0]->recipients[0]);
     $recipents[] = strval($emailMessages[1]->recipients[0]);
     $this->assertEquals(1, count($emailMessages[0]->recipients));
     $this->assertEquals(1, count($emailMessages[1]->recipients));
     $this->assertNotContains(strval($super->primaryEmail), $recipents);
     $this->assertNotContains(strval($steven->primaryEmail), $recipents);
     $this->assertContains(strval($mary->primaryEmail), $recipents);
     $this->assertContains(strval($sally->primaryEmail), $recipents);
     $this->assertEquals(4, User::getCount());
 }