コード例 #1
0
 /**
  * @param DB_DataObject $class
  * @param string $label
  * @param string $field
  * @return array
  */
 function getSessionFilterSubTable($class, $label, $field)
 {
     $class->orderBy('value ASC');
     $class->find();
     $filter = array();
     $filter['label'] = $label;
     $filter['field'] = $field;
     $filter['values'] = array();
     $filter['values']['null'] = 'unset';
     while ($class->fetch()) {
         $filter['values'][$class->id] = $class->value;
     }
     natcasesort($filter['values']);
     return $filter;
 }
コード例 #2
0
 function showContent()
 {
     $properties = ['id', 'nickname', 'fullname', 'profileurl', 'homepage', 'bio', 'location', 'lat', 'lon', 'location_id', 'location_ns', 'created', 'modified'];
     // $config['staleaccounts']['inactive_period'] is number of months
     // of inactivity before an account is considered stale.
     // Defaults to 3
     $inactive_period = common_config('staleaccounts', 'inactive_period') ?: 3;
     // Calculate stale date (today - $inactive_period)
     $stale_date = new DateTime();
     $stale_date->modify('-' . $inactive_period . ' month');
     $stale_date = $stale_date->format('Y-m-d');
     $offset = ($this->page - 1) * PROFILES_PER_PAGE;
     $limit = PROFILES_PER_PAGE + 1;
     $dataObj = new DB_DataObject();
     // Custom query because I only want to hit the db once
     $dataObj->query('SELECT * FROM
         (
             SELECT local_profiles.*, MAX(n.created) as latest_activity FROM
             (
                 SELECT p.*
                 FROM profile p
                 JOIN user u ON u.id = p.id
             ) local_profiles
             LEFT JOIN notice n ON local_profiles.id = n.profile_id
             GROUP BY local_profiles.id
             ORDER BY latest_activity
         ) z
         WHERE z.latest_activity < "' . $stale_date . '"
         OR z.latest_activity IS NULL
         LIMIT ' . $offset . ', ' . $limit . ';');
     $cnt = $dataObj->N;
     $this->elementStart('ul');
     while ($dataObj->fetch()) {
         $profile = new Profile();
         foreach ($properties as $property) {
             $profile->{$property} = $dataObj->{$property};
         }
         $profile->latest_activity = $dataObj->latest_activity;
         $pli = new StaleProfileListItem($profile, $this);
         $pli->show();
     }
     $this->elementEnd('ul');
     $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->page, 'staleaccounts', $this->args);
 }
コード例 #3
0
ファイル: Library.php プロジェクト: victorfcm/VuFind-Plus
 /**
  * Override the fetch functionality to save related objects
  *
  * @see DB/DB_DataObject::fetch()
  */
 public function fetch()
 {
     $return = parent::fetch();
     if ($return) {
         if (isset($this->showInMainDetails) && is_string($this->showInMainDetails) && !empty($this->showInMainDetails)) {
             // convert to array retrieving from database
             $this->showInMainDetails = unserialize($this->showInMainDetails);
             if (!$this->showInMainDetails) {
                 $this->showInMainDetails = array();
             }
         } elseif (empty($this->showInMainDetails)) {
             // when a value is not set, assume set to show all options, eg null = all
             $default = self::$showInMainDetailsOptions;
             // remove options below that aren't to be part of the default
             unset($default['showISBNs']);
             $default = array_keys($default);
             $this->showInMainDetails = $default;
         }
     }
     return $return;
 }
コード例 #4
0
ファイル: Pluggable.php プロジェクト: demental/m
 function fetch()
 {
     $this->trigger('prefetch');
     if (parent::fetch()) {
         $this->_memoized = array();
         $this->trigger('postfetch');
         return true;
     }
     return false;
 }
コード例 #5
0
 public function fetch()
 {
     // avoid those annoying PEAR::DB strict standards warnings it causes
     $old = error_reporting();
     error_reporting(error_reporting() & ~E_STRICT);
     $res = parent::fetch();
     // reset
     error_reporting($old);
     return $res;
 }