Example #1
0
 /**
  * @param CM_Model_User $user
  * @param int|null      $actionType
  * @param int|null      $actionVerb
  * @param int|null      $period
  * @param int|null      $upperBound
  */
 public function __construct(CM_Model_User $user, $actionType = null, $actionVerb = null, $period = null, $upperBound = null)
 {
     $cacheEnabled = false;
     $this->_user = $user;
     $period = (int) $period;
     $where = 'actorId=' . $user->getId() . ' AND `actionLimitType` IS NULL';
     if ($actionType) {
         $actionType = (int) $actionType;
         $where .= ' AND `type` = ' . $actionType;
     }
     if ($actionVerb) {
         $actionVerb = (int) $actionVerb;
         $where .= ' AND `verb` = ' . $actionVerb;
     }
     if ($period) {
         if (null !== $upperBound) {
             $upperBound = (int) $upperBound;
             $cacheEnabled = true;
         } else {
             $upperBound = time();
         }
         $lowerBound = $upperBound - $period;
         $where .= ' AND `createStamp` > ' . $lowerBound . ' AND `createStamp` <= ' . $upperBound;
     }
     $source = new CM_PagingSource_Sql_Deferred('type, verb, createStamp', 'cm_action', $where, '`createStamp` DESC');
     if ($cacheEnabled) {
         $source->enableCacheLocal();
     }
     parent::__construct($source);
 }
Example #2
0
 /**
  * @param int $type
  */
 public function __construct($type)
 {
     $this->_type = (int) $type;
     $source = new CM_PagingSource_Sql_Deferred('string', 'cm_string', '`type`=' . $this->_type, 'string ASC');
     $source->enableCache();
     parent::__construct($source);
 }
Example #3
0
 /**
  * @param CM_Model_Language $language
  * @param bool|null         $javascriptOnly
  */
 public function __construct(CM_Model_Language $language, $javascriptOnly = null)
 {
     $this->_language = $language;
     $this->_javascriptOnly = (bool) $javascriptOnly;
     $where = null;
     if ($javascriptOnly) {
         $where = 'k.javascript = 1';
         // Include the javascript version in the cache key, so the paging invalidates when the version changes.
         $javascriptVersion = CM_Model_Language::getVersionJavascript();
         $where .= " AND '{$javascriptVersion}' = '{$javascriptVersion}'";
     }
     $orderBy = 'k.name ASC';
     $join = 'LEFT JOIN `cm_languageValue` AS v ON k.id = v.languageKeyId AND v.languageId = ' . $this->_language->getId() . ' ';
     $groupBy = 'BINARY k.name';
     $source = new CM_PagingSource_Sql_Deferred('k.name AS `key`, v.value, k.variables', 'cm_model_languagekey` as `k', $where, $orderBy, $join, $groupBy);
     $source->enableCache(null, CM_Cache_Persistent::getInstance());
     parent::__construct($source);
 }