count() public method

Counts all elements in the array
public count ( ) : integer
return integer
Example #1
0
 public function testClone()
 {
     $clone = $this->collection->clone();
     $clone->push('test');
     $this->assertEquals(4, $this->collection->count());
     $this->assertEquals(5, $clone->count());
 }
 /**
  * {@inheritdoc}
  */
 public function count()
 {
     if ($this->mapping['isInverseSide']) {
         $this->initialize();
     }
     return count($this->mongoData) + $this->coll->count();
 }
Example #3
0
 public function testAddsAllElements()
 {
     $list = new Collection(\Cassandra::TYPE_VARINT);
     $list->add(new Varint('1'), new Varint('2'), new Varint('3'), new Varint('4'), new Varint('5'), new Varint('6'), new Varint('7'), new Varint('8'));
     $this->assertEquals(8, $list->count());
     $this->assertEquals(array(new Varint('1'), new Varint('2'), new Varint('3'), new Varint('4'), new Varint('5'), new Varint('6'), new Varint('7'), new Varint('8')), $list->values());
 }
 /**
  * Return a list of available configuration options.
  *
  * @param Collection $availableTypes Collection of Injector\InjectorInterface::TYPE_*
  *     constants indicating valid package types that could be injected.
  * @param string $projectRoot Path to the project root; assumes PWD by
  *     default.
  * @return Collection Collection of ConfigOption instances.
  */
 public function getAvailableConfigOptions(Collection $availableTypes, $projectRoot = '')
 {
     // Create an initial collection to which we'll append.
     // This approach is used to ensure indexes are sane.
     $discovered = new Collection([new ConfigOption('Do not inject', new Injector\NoopInjector())]);
     Collection::create($this->discovery)->map(function ($discoveryClass) use($projectRoot) {
         if (is_array($discoveryClass)) {
             return new ConfigDiscovery\DiscoveryChain($discoveryClass, $projectRoot);
         }
         return new $discoveryClass($projectRoot);
     })->filter(function ($discovery) {
         return $discovery->locate();
     })->map(function ($discovery, $file) use($projectRoot, $availableTypes) {
         // Look up the injector based on the file type
         $injectorClass = $this->injectors[$file];
         if (is_array($injectorClass)) {
             return new Injector\ConfigInjectorChain($injectorClass, $discovery, $availableTypes, $projectRoot);
         }
         return new $injectorClass($projectRoot);
     })->filter(function ($injector) use($availableTypes) {
         return $availableTypes->reduce(function ($flag, $type) use($injector) {
             return $flag || $injector->registersType($type);
         }, false);
     })->each(function ($injector, $file) use($discovered) {
         $discovered[] = new ConfigOption($file, $injector);
     });
     return 1 === $discovered->count() ? new Collection([]) : $discovered;
 }
Example #5
0
 /**
  * Find element from collection by key and value
  * 
  * @param string $key - search index
  * @param string $value - search value
  * @param [boolean $onlyIndex] - this flag can return only indixes of records found
  * @return NULL|Collection <NULL, \VCAPI\Common\Collection>
  */
 public function find($key, $value, $onlyIndex = false)
 {
     if (empty($this->collection)) {
         return null;
     }
     $return = new Collection();
     foreach ($this->collection as $index => $item) {
         if (is_array($item)) {
             if (!isset($item[$key])) {
                 continue;
             }
             if ($item[$key] == $value) {
                 if ($onlyIndex) {
                     $return->add($index);
                 } else {
                     $return->add($item);
                 }
             }
         } elseif (is_object($item)) {
             if (!property_exists($item, $key)) {
                 continue;
             }
             if ($item->{$key} == $value) {
                 if ($onlyIndex) {
                     $return->add($index);
                 } else {
                     $return->add($item);
                 }
             }
         }
     }
     return $return->count() ? $return : null;
 }
Example #6
0
 /**
  * Dynamically retrieve attributes on the model.
  *
  * @param  string $key
  *
  * @return Collection
  */
 public function __get($key)
 {
     $newCollection = new Collection();
     foreach ($this->items as $item) {
         if ($item instanceof Collection) {
             foreach ($item as $subItem) {
                 $newCollection->put($newCollection->count(), $subItem->{$key});
             }
         } elseif (is_object($item) && !$item instanceof Collection && $item->{$key} instanceof Collection) {
             foreach ($item->{$key} as $subItem) {
                 $newCollection->put($newCollection->count(), $subItem);
             }
         } else {
             $newCollection->put($newCollection->count(), $item->{$key});
         }
     }
     return $newCollection;
 }
 /**
  * Add a new category that list items
  *
  * @param \Amisure\P4SApiBundle\Entity\EvaluationItemCategory|string $category
  *        	Evaluation item category, or name of the evaluation item category
  * @see \Amisure\P4SApiBundle\Entity\EvaluationItemCategory
  * @return \Amisure\P4SApiBundle\Entity\Evaluation
  */
 public function addCategory($category)
 {
     $evaluationCategory = $category;
     if (is_string($category)) {
         $evaluationCategory = new EvaluationModelCategory($category);
     }
     $evaluationCategory->setEvaluation($this);
     if (-1 == $evaluationCategory->getCategoryId()) {
         $evaluationCategory->setCategoryId($this->categories->count());
     }
     $this->categories->add($evaluationCategory);
     return $this;
 }
 /**
  * Add a new item
  *
  * @param \Amisure\P4SApiBundle\Entity\EvaluationModelItem|string $item
  *        	Evaluation item, or description of the evaluation item
  * @param string $value
  *        	Value of the evaluation item if the evaluation item itself is not previsously provided
  * @see \Amisure\P4SApiBundle\Entity\EvaluationModelItem
  * @return \Amisure\P4SApiBundle\Entity\EvaluationModelCategory
  */
 public function addItem($item, $responseType = '')
 {
     $evaluationItem = $item;
     if (is_string($item)) {
         $evaluationItem = new EvaluationModelItem($item, $responseType);
     }
     $evaluationItem->setCategory($this);
     if (-1 == $evaluationItem->getItemId()) {
         $evaluationItem->setItemId($this->items->count());
     }
     $this->items->add($evaluationItem);
     return $this;
 }
 /**
  * Add a new item response
  *
  * @param \Amisure\P4SApiBundle\Entity\EvaluationModelItemResponse|string $item
  *        	Evaluation item, or description of the evaluation item
  * @param string $label
  *        	Label of the evaluation item response if the evaluation item response itself is not previsously provided
  * @param string $type
  *        	Type of the evaluation item response if the evaluation item response itself is not previsously provided
  * @see \Amisure\P4SApiBundle\Entity\EvaluationModelItem
  * @return \Amisure\P4SApiBundle\Entity\EvaluationModelItem
  */
 public function addResponse($response, $label = '', $type = EvaluationModelItemResponse::TypeString)
 {
     $evaluationResponse = $response;
     if (is_string($response)) {
         $evaluationResponse = new EvaluationModelItem($response, $label, $type);
     }
     $evaluationResponse->setItem($this);
     if (-1 == $evaluationResponse->getResponseId()) {
         $evaluationResponse->setResponseId($this->responses->count());
     }
     $this->responses->add($evaluationResponse);
     return $this;
 }
Example #10
0
 public function test3_Appending()
 {
     $collection = new Collection(new Yaml());
     $collection_of_values = new Collection(new Yaml());
     # appending
     static::$collection->append('part1.item2', ['name' => 'Janice']);
     $this->assertEquals('Janice', static::$collection->get('part1.item2.name'));
     static::$collection->forget('part1');
     static::$collection->append('part1', ['item2' => ['name' => 'Janice']]);
     static::$collection->with('with', 'with test');
     $this->assertEquals('with test', static::$collection->get('with'));
     $this->assertTrue(static::$collection->count() === 2);
     static::$collection->forget('with');
     $this->assertTrue(static::$collection->count() === 1);
     # setup
     $test_array = ['merge_with' => ['merge' => 'this']];
     $collection_of_values->with($test_array);
     # test with an array
     $collection->merge($test_array);
     $this->assertEquals($collection->get('merge_with.merge'), 'this');
     $collection->forget('merge_with');
     # test with a collection as a value object
     $collection->merge($collection_of_values);
     $this->assertEquals($collection->get('merge_with.merge'), 'this');
     $collection->forget('merge_with');
     # test with value object
     $value_object = new \stdClass();
     $value_object->merge_with = $test_array['merge_with'];
     $collection->merge($value_object);
     $this->assertEquals($collection->get('merge_with.merge'), 'this');
     # test with flat array
     $collection->merge(Util::array_from_str('merge with'));
     $this->assertEquals($collection->get('merge'), NULL);
     $this->assertEquals($collection->get('with'), NULL);
     $this->setExpectedException('InvalidArgumentException', "Cannot append an already existing key: 'part1'");
     static::$collection->append('part1', ['item2' => ['name' => 'Mary']]);
 }
Example #11
0
 /**
  * build a Collection object with objects of this class based on filters
  *
  * @param Array $filters
  * @param string|null $order literal SQL appended to "ORDER BY " if used.
  * @returns Collection object
  */
 public static function buildCollection($filters, $order = null)
 {
     Debug::log(">>" . get_called_class() . ":: " . __FUNCTION__ . " called with filters:", $filters);
     $collection = new Collection();
     $sql = static::buildCollectionSql($params, $filters, $order);
     $stmt = static::getConnection()->prepAndExecute(new \ArtfulRobot\PDO_Query("Fetch records from " . static::TABLE_NAME, $sql, $params));
     if ($stmt->errorCode() != '00000') {
         throw new Exception("PDO error: " . print_r($stmt->errorInfo(), 1));
     }
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         // create an object of the class
         $obj = new static();
         $obj->loadFromArray($row, false, self::CAST_DB);
         $collection->append($obj, $obj->id);
         unset($obj);
     }
     Debug::log("<< Returning collection with " . $collection->count() . " entries");
     return $collection;
 }
Example #12
0
 /**
  * Get the number of public properties in the ArrayObject
  * @return int
  */
 public function count()
 {
     if (!$this->isLoaded() && $this->isLoadable()) {
         $this->load();
     }
     return parent::count();
 }
Example #13
0
 /**
  * Check node children
  *
  * @return bool
  */
 public function hasChildren()
 {
     return $this->_childNodes->count() > 0;
 }
Example #14
0
<?php

include "../patches.php";
$patch = new Patch(18);
if (!$patch->exists()) {
    $createSql = "CREATE TABLE IF NOT EXISTS `webcam_images` (\n\t\t\t  `timestamp` datetime NOT NULL,\n\t\t\t  `image_id` bigint(11) unsigned NOT NULL,\n\t\t\t  `user_id` int(11) unsigned NOT NULL,\n\t\t\t  `bot_id` int(11) unsigned NULL,\n\t\t\t  `job_id` int(11) unsigned NULL,\n\t\t\t  PRIMARY KEY (`timestamp`, `image_id`),\n\t\t\t  FOREIGN KEY (`image_id`) REFERENCES s3_files(`id`) ON DELETE CASCADE,\n\t\t\t  FOREIGN KEY (`user_id`) REFERENCES users(`id`) ON DELETE CASCADE,\n\t\t\t  FOREIGN KEY (`bot_id`) REFERENCES bots(`id`) ON DELETE CASCADE,\n\t\t\t  FOREIGN KEY (`job_id`) REFERENCES jobs(`id`) ON DELETE CASCADE\n\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
    db()->execute($createSql);
    $failCount = 0;
    $rowSql = "SELECT id from jobs where webcam_images!=''";
    $jobsCollection = new Collection($rowSql);
    $jobsCollection->bindType('id', 'Job');
    $jobs = $jobsCollection->getAll();
    $total = $jobsCollection->count();
    $count = 0;
    $patch->progress(0);
    // Get the current webcam images in an array, so we can quickly skip those.
    $pdoStatement = db()->query("SELECT image_id from webcam_images");
    $existingImages = array();
    foreach ($pdoStatement->fetchAll(PDO::FETCH_ASSOC) as $row) {
        $existingImages[$row['image_id']] = true;
    }
    foreach ($jobs as $row) {
        /** @var Job $job */
        $job = $row['Job'];
        $images_json = $job->get('webcam_images');
        if ($job->isHydrated() && $images_json != "") {
            $images = json_decode($images_json, true);
            $rowData = array();
            foreach ($images as $timestamp => $image_id) {
                if (!array_key_exists($image_id, $existingImages)) {
                    $file = Storage::get($image_id);
Example #15
0
 /**
  * @return bool
  */
 public function hasGists()
 {
     return $this->gists->count() > 0;
 }
Example #16
0
 /**
  * 
  * @param Subject $child
  * @return boolean
  */
 function hasChildren()
 {
     return $this->children->count() > 0;
 }
 /**
  * @author Alexander Zelensky
  * @todo Возможно, в будущем здесь нужно будет добавить проверку параметра, использовать ли вообще мультиязычность по сегментам урла, или нет. Например, удобно будет отключить мультиязычность по сегментам при использовании разных доменных имен для каждой языковой версии.
  */
 public static function returnRoutes($prefix = null)
 {
     #Helper::dd(I18nPage::count());
     $class = __CLASS__;
     /**
      * Laravel не дает возможности переписывать пути (роуты), если они были зарегистрированы ранее.
      * А это значит, что если данный модуль активен и в нем создана хоть одна страница, то будет переписан корневой путь: /
      * Это не даст в будущем добавлять роуты от корня с помощью метода Route::controller('', '..@..'), придется все прописывать руками.
      * Надо бы подключать модуль страниц последним
      * [
      *     '/login' => Route object to /login,
      *     '{_missing}' => Fallthrough route object,
      *     '/' => Route object to /,
      * ]
      * Описание данной ситуации здесь:
      * http://stackoverflow.com/questions/20617244/laravel-4-1-controller-method-not-found?rq=1
      * https://github.com/laravel/framework/issues/2848
      * https://github.com/laravel/framework/pull/2850
      * https://github.com/laravel/framework/issues/2863
      * https://github.com/bencorlett/framework/pull/1
      * https://github.com/bencorlett/framework/commit/ac091a25465d070f8925a80b46eb237ef21ea912
      */
     if (!Allow::module(self::$group) || Config::get('site.pages.disabled')) {
         return false;
     }
     Page::preload();
     ##
     ## Add URL modifier for check SEO url of the page (custom UrlGenerator functionality)
     ##
     /*
     URL::add_url_modifier('page', function(&$name, &$parameters) use ($class) {
         #var_dump($class); die;
         #Helper::dd('Page url modifier!');
         #Helper::dd($parameters);
         #return;
         if (
             #is_string($parameters)
             #&&
             count(Config::get('app.locales')) > 1
             && !Config::get('pages.disable_url_modification')
             && Allow::module('seo')
         ) {
             $pages = new $class;
             $right_url = $pages->getRightPageUrl($parameters);
             #Helper::d("Change page URL: " . $parameters . " -> " . $right_url);
             #Helper::dd("Change page URL: " . $parameters . " -> " . $right_url);
             if (@$right_url)
                 $parameters = $right_url;
             #$parameters = '111';
         }
     });
     */
     #/*
     if (count(Config::get('app.locales')) > 1 && !Config::get('pages.disable_url_modification')) {
         ## Mainpage route modifier
         URL::add_url_modifier('mainpage', function (&$name, &$parameters) use($class) {
             #print_r($parameters);
             if (isset($parameters['lang']) && $parameters['lang'] == Config::get('app.default_locale')) {
                 unset($parameters['lang']);
             }
             #print_r($parameters);
         });
     }
     #*/
     ## Будем генерим отдельные роуты для "параметризированных" страниц: у которых в slug есть параметр(ы) (например: {city}/hello)
     ## Как будем искать страницы - в кеше или в БД?
     if (Config::get('pages.not_cached')) {
         ## Кеширование отключено (или не найдено ни одной страницы) - ищем в БД
         #$page = (new Page())->where('publication', 1)->where('version_of', NULL);
         $pages_parametrized = Page::where('parametrized', 1)->get();
     } else {
         $pages_parametrized = new Collection();
         ## Если страниц нет в кеше - показываем 404
         if (null != ($temp = Page::all_by_slug()) && count($temp)) {
             #Helper::tad($temp);
             foreach ($temp as $tmp) {
                 if ($tmp->parametrized) {
                     $pages_parametrized[$tmp->slug] = $tmp;
                 }
             }
         }
     }
     #Helper::tad($pages_parametrized);
     ## Если в конфиге прописано несколько языковых версий - генерим роуты с языковым префиксом
     if (is_array(Config::get('app.locales')) && count(Config::get('app.locales')) > 1) {
         $default_locale_mainpage = Config::get('app.default_locale') == Config::get('app.locale');
         #$locale_sign = Config::get('app.locale');
         ## Генерим роуты для всех языков с префиксом (первый сегмент), который будет указывать на текущую локаль
         Route::group(array('before' => 'i18n_url', 'prefix' => '{lang}'), function () use($class, $default_locale_mainpage, $pages_parametrized) {
             ## Генерим роуты для параметризированных страниц
             if ($pages_parametrized->count()) {
                 foreach ($pages_parametrized as $page) {
                     Route::any($page->slug, array('as' => 'page.' . $page->sysname, 'uses' => $class . '@showPageParametrize'));
                 }
             }
             ## Regular page
             Route::any('/{url}', array('as' => 'page', 'uses' => $class . '@showPage'));
             ## Main page for non-default locale
             #if (!Config::get('pages.disable_mainpage_route') && !$default_locale_mainpage)
             #    Route::any('/', array('as' => 'mainpage', 'uses' => $class.'@showPage'));
             ## Main page for current locale (non-default)
             #Route::any('/', array('as' => 'mainpage_i18n', 'uses' => $class.'@showPage'));
         });
         Route::any('{lang?}', array('as' => 'mainpage', 'uses' => $class . '@showPage'));
         ## Main page for default locale
         #if (!Config::get('pages.disable_mainpage_route') && $default_locale_mainpage)
         #    Route::any('/', array('as' => 'mainpage', 'uses' => $class.'@showPage'));
         ## Main page for default locale
         #Route::any('/', array('as' => 'mainpage_default', 'uses' => $class.'@showPage'));
     } else {
         ## Генерим роуты без языкового префикса
         Route::group(array('before' => 'pages_right_url'), function () use($class, $pages_parametrized) {
             ## Генерим роуты для параметризированных страниц
             if ($pages_parametrized->count()) {
                 foreach ($pages_parametrized as $page) {
                     Route::any($page->slug, array('as' => 'page.' . $page->sysname, 'uses' => $class . '@showPageSingleParametrize'));
                 }
             }
             ## Regular page
             Route::any('{url}', array('as' => 'page', 'uses' => $class . '@showPageSingle'));
             ## Main page
             if (!Config::get('pages.disable_mainpage_route')) {
                 Route::any('/', array('as' => 'mainpage', 'uses' => $class . '@showPageSingle'));
             }
         });
     }
     /*
             #dd(Route::getRoutes());
             $routes = Route::getRoutes();
             foreach($routes as $route) {
                 echo $route->getPath() . "<br/>";
             }
             die;
             #*/
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public function count()
 {
     $this->_initialize();
     return $this->_coll->count();
 }
Example #19
0
 /**
  * Checks if the collection has more elements
  *
  * @return boolean
  */
 public function valid()
 {
     return $this->_currentIndex < $this->_collection->count();
 }
Example #20
0
 /**
  * Try to retrieve the id and return a collection of the corresponding objects
  *  thanks to another unique identifier passed as argument
  * If the function can't find an object for each identifier passed, it must throw
  *  an ItemNotFoundException
  *
  * @param $mixed  An array containing a unique identifier (often it's a unique name)
  */
 public static function batchFrom(array $mixed)
 {
     // The schema may specify a key
     $schema = Schema::get(get_called_class());
     $className = $schema->className();
     $key = $schema->fromKey();
     if (empty($key)) {
         throw new Exception("batchFrom isn't implemented");
     }
     $collec = new Collection();
     if (!empty($mixed)) {
         $iter = XDB::iterator('SELECT  ' . $schema->id() . ' AS id, ' . $key . '
                                  FROM  ' . $schema->table() . '
                                 WHERE  ' . $key . ' IN {?}', $mixed);
         while ($data = $iter->next()) {
             $collec->add(new $className($data));
         }
         if ($collec->count() == 0) {
             throw new ItemNotFoundException('Nothing found for ' . implode(', ', $mixed));
         }
         if (count($mixed) != $collec->count()) {
             throw new ItemNotFoundException('Asking for ' . implode(', ', $mixed) . ' but only found ' . implode(', ', $collec->ids()));
         }
     }
     return $collec;
 }
Example #21
0
 function handler_group_ajax_users($page)
 {
     $group = Json::i('gid');
     $limit = 25;
     $group = Group::fromId($group);
     $users = false;
     if ($group) {
         $users = array();
         $group->select(GroupSelect::castes());
         $order = new UFO_Name(UFO_Name::LASTNAME);
         $filters = new PFC_True();
         if (strlen(Json::t('promo')) > 0) {
             $filters = new UFC_Group(explode(';', Json::v('promo')));
         }
         $uf = new UserFilter(new PFC_And(new UFC_Caste($group->caste(Rights::admin())), $filters), $order);
         $admins = $uf->get(new PlLimit($limit, (Json::i('admin_page', 1) - 1) * $limit));
         $admins_total = $uf->getTotalCount();
         $uf = new UserFilter(new PFC_And(new UFC_Caste(array($group->caste(Rights::member()), $group->caste(Rights::logic()))), $filters), $order);
         $members = $uf->get(new PlLimit($limit, (Json::i('member_page', 1) - 1) * $limit));
         $members_total = $uf->getTotalCount();
         $uf = new UserFilter(new PFC_And(new UFC_Caste($group->caste(Rights::friend())), $filters), $order);
         $friends = $uf->get(new PlLimit($limit, (Json::i('friend_page', 1) - 1) * $limit));
         $friends_total = $uf->getTotalCount();
         $all = new Collection('User');
         $all->safeMerge(array($admins, $members, $friends));
         $all->select(UserSelect::base());
         $admins_export = $admins->export(User::EXPORT_MICRO, true);
         $members_export = $members->export(User::EXPORT_MICRO, true);
         $friends_export = $friends->export(User::EXPORT_MICRO, true);
         if ($all->count() > 0) {
             $iter = XDB::iterRow('SELECT  uid, comment
                                     FROM  users_comments
                                    WHERE  gid = {?} AND uid IN {?}', $group->id(), $all->ids());
             while (list($uid, $comment) = $iter->next()) {
                 if ($admins_export[$uid]) {
                     $admins_export[$uid]['comments'] = $comment;
                 }
                 if ($members_export[$uid]) {
                     $members_export[$uid]['comments'] = $comment;
                 }
                 if ($friends_export[$uid]) {
                     $friends_export[$uid]['comments'] = $comment;
                 }
             }
         }
         $users['admin'] = array('total' => $admins_total, 'users' => $admins_export);
         $users['member'] = array('total' => $members_total, 'users' => $members_export);
         $users['friend'] = array('total' => $friends_total, 'users' => $friends_export);
     }
     $page->jsonAssign('limit', $limit);
     $page->jsonAssign('users', $users);
     return PL_JSON;
 }
Example #22
0
        $u->comments($g, conv($g_datas['remarque']));
        if ($g->id() == 1 && strlen(conv_name($u->nickname())) > 1) {
            $u->addStudy(0, $datas['promo'], (int) $datas['promo'] + 4, $datas['promo'], conv_name($u->nickname()));
        }
    }
    $temp = new Collection('Group');
    $temp->safeMerge(array($groups_member, $groups_friend));
    $temp->select(GroupSelect::castes());
    foreach ($groups_member as $g) {
        $g->caste(Rights::member())->addUser($u);
    }
    foreach ($groups_friend as $g) {
        $g->caste(Rights::friend())->addUser($u);
    }
    $k++;
    echo 'User ' . str_pad($k, 4, '0', STR_PAD_LEFT) . '/' . $users . ' : ' . str_pad($u->id(), 5, '0', STR_PAD_LEFT) . ' - ' . $datas['promo'] . ' - ' . str_pad($groups_member->count(), 2, '0', STR_PAD_LEFT) . " members - " . str_pad($groups_friend->count(), 2, '0', STR_PAD_LEFT) . " friends - " . substr(microtime(true) - $t, 0, 5) . '   ' . $u->login() . "\n";
}
echo "-----------------------------------------------\n";
XDB::execute('UPDATE account SET skin = "default"');
echo "default skin set \n";
XDB::execute('INSERT INTO users_minimodules
                          (SELECT uid, "birthday",     "COL_LEFT",   0 FROM account WHERE uid > 0)');
XDB::execute('INSERT INTO users_minimodules
                          (SELECT uid, "days",         "COL_LEFT",   1 FROM account WHERE uid > 0)');
XDB::execute('INSERT INTO users_minimodules
                          (SELECT uid, "ik",           "COL_LEFT",   2 FROM account WHERE uid > 0)');
XDB::execute('INSERT INTO users_minimodules
                          (SELECT uid, "qdj",          "COL_MIDDLE", 0 FROM account WHERE uid > 0)');
XDB::execute('INSERT INTO users_minimodules
                          (SELECT uid, "jtx",          "COL_MIDDLE", 1 FROM account WHERE uid > 0)');
XDB::execute('INSERT INTO users_minimodules
Example #23
0
 /**
  * Same as visibilityInfo, but for visibility collections
  */
 public static function visibilitiesColInfo(Collection $visibilities)
 {
     if ($visibilities->count() == 0) {
         return array('green', "Tout le monde");
     } elseif ($visibilities->count() == 1) {
         return self::visibilityInfo($visibilities->first());
     }
     $textes = array();
     foreach ($visibilities as $v) {
         list($color, $text) = self::visibilityInfo($v);
         $textes[] = $text;
     }
     return array('grey', implode(', ', $textes));
 }
Example #24
0
 public function selectRights(Collection $users)
 {
     $rights = array();
     if ($users->count() > 0) {
         $iter = XDB::iterRow('SELECT  cu.uid, c.rights
                                  FROM  castes AS c
                            INNER JOIN  castes_users AS cu ON (cu.cid = c.cid
                                        AND (cu.visibility IN {?} OR cu.uid = {?}))
                            INNER JOIN  groups AS g ON g.gid = c.`group`
                                 WHERE  g.gid = {?} AND cu.uid IN {?}', S::user()->visibleGids(), S::user()->id(), $this->id(), $users->ids());
         while (list($uid, $right) = $iter->next()) {
             if (empty($rights[$uid])) {
                 $rights[$uid] = array();
             }
             $rights[$uid][] = new Rights($right);
         }
     }
     return $rights;
 }
Example #25
0
 public function testMergeCollection()
 {
     $this->collection->merge(new Collection(['test']));
     $this->assertEquals(5, $this->collection->count());
     $this->assertEquals('test', $this->collection->last());
 }
 /**
  * {@inheritdoc}
  */
 public function count()
 {
     return count($this->mongoData) + $this->coll->count();
 }
Example #27
0
 /**
  * @return int
  */
 public function count()
 {
     return $this->discounts->count();
 }
Example #28
0
 /**
  * @return bool
  */
 public function hasComments()
 {
     return $this->comments->count() > 0;
 }
 /**
  * @return int
  */
 function count()
 {
     $this->load();
     return parent::count();
 }
 /**
  * {@inheritdoc}
  */
 public function isEmpty()
 {
     return $this->coll->count() === 0 ? true : false;
 }