Example #1
0
 /**
  * Overwrite fetchAll to provide a default sorting by the configured display name.
  */
 public function fetchAll($where = null, $order = null, $count = null, $offset = null, $select = null, $join = null)
 {
     if (is_null($order)) {
         $order = self::getDisplay();
     }
     return parent::fetchAll($where, $order, $count, $offset, $select, $join);
 }
Example #2
0
 /**
  * Rewrites parent fetchAll, only public records are shown.
  *
  * @param string|array $where  Where clause.
  * @param string|array $order  Order by.
  * @param string|array $count  Limit query.
  * @param string|array $offset Query offset.
  * @param string       $select The comma-separated columns of the joined columns.
  * @param string       $join   The join statements.
  *
  * @return Zend_Db_Table_Rowset The rowset with the results.
  */
 public function fetchAll($where = null, $order = null, $count = null, $offset = null, $select = null, $join = null)
 {
     // Set where
     if (null !== $where) {
         $where .= ' AND ';
     }
     $where .= sprintf('(owner_id = %d OR private = 0)', (int) Phprojekt_Auth::getUserId());
     return Phprojekt_ActiveRecord_Abstract::fetchAll($where, $order, $count, $offset, $select, $join);
 }
Example #3
0
 /**
  * Rewrites parent fetchAll, so that only records with read access are shown.
  *
  * @param string|array $where  Where clause.
  * @param string|array $order  Order by.
  * @param string|array $count  Limit query.
  * @param string|array $offset Query offset.
  * @param string       $select The comma-separated columns of the joined columns.
  * @param string       $join   The join statements.
  *
  * @return Zend_Db_Table_Rowset The rowset with the results.
  */
 public function fetchAll($where = null, $order = null, $count = null, $offset = null, $select = null, $join = null)
 {
     // Only fetch records with read access
     if (!Phprojekt_Auth::isAdminUser()) {
         $join .= sprintf(' INNER JOIN item_rights ON (item_rights.item_id = %s
             AND item_rights.module_id = %d AND item_rights.user_id = %d) ', $this->getAdapter()->quoteIdentifier($this->getTableName() . '.id'), Phprojekt_Module::getId($this->getModelName()), Phprojekt_Auth_Proxy::getEffectiveUserId());
         // Set where
         if (null !== $where) {
             $where .= ' AND ';
         }
         $where .= ' (' . sprintf('(%s.owner_id = %d OR %s.owner_id IS NULL)', $this->getTableName(), Phprojekt_Auth_Proxy::getEffectiveUserId(), $this->getTableName());
         $where .= sprintf(' OR ((item_rights.access & %d) = %d)) ', Phprojekt_Acl::READ, Phprojekt_Acl::READ);
     }
     return parent::fetchAll($where, $order, $count, $offset, $select, $join);
 }
Example #4
0
 /**
  * Return all the events for all the users selected in a date.
  * The function use the ActiveRecord fetchAll for skip the itemRights restrictions.
  *
  * @param string  $usersId User IDs comma separated.
  * @param string  $date    Date for search.
  * @param integer $count   Count for the fetchall.
  * @param integer $offset  Offset for the fetchall.
  *
  * @return array Array of Calendar_Models_Calendar.
  */
 public function getUserSelectionRecords($usersId, $date, $count, $offset)
 {
     $db = Phprojekt::getInstance()->getDb();
     $date = $db->quote($date);
     $records = array();
     if (count($usersId) > 0) {
         $where = sprintf('participant_id IN (%s) AND DATE(start_datetime) <= %s AND DATE(end_datetime) >= %s', implode(", ", $usersId), $date, $date);
         $records = Phprojekt_ActiveRecord_Abstract::fetchAll($where, null, $count, $offset);
         // Hide the title, place and note from the private events
         $userId = Phprojekt_Auth::getUserId();
         foreach ($records as $key => $record) {
             if ($record->visibility == 1 && $record->participantId != $userId) {
                 $record->title = "-";
                 $record->notes = "-";
                 $record->place = "-";
             }
         }
     }
     return $records;
 }
Example #5
0
 /**
  * Returns an array of all calendar objects for the given uid.
  *
  * @param string The uid of the calendar collection
  *
  * @return array of Calendar2_Models_Calendar2 All objects belonging to that uid
  */
 public function fetchByUid($uid)
 {
     $db = Phprojekt::getInstance()->getDb();
     $where = $db->quoteInto('uid = ?', $uid);
     return Phprojekt_ActiveRecord_Abstract::fetchAll($where);
 }
Example #6
0
 /**
  * Customized version to calculate the status of a minutes item regardless of its saved database entry.
  *
  * @param string|array $where  Where clause.
  * @param string|array $order  Order by.
  * @param string|array $count  Limit query.
  * @param string|array $offset Query offset.
  * @param string       $select The comma-separated columns of the joined columns.
  * @param string       $join   The join statements.
  *
  * @return Zend_Db_Table_Rowset The rowset with the results.
  */
 public function fetchAll($where = null, $order = array('sort_order ASC', 'id DESC'), $count = null, $offset = null, $select = null, $join = null)
 {
     if (null !== $where) {
         $where .= ' AND ';
     }
     $where .= sprintf('(%s.%s = %d )', $this->_db->quoteIdentifier($this->getTableName()), $this->_db->quoteIdentifier('minutes_id'), empty($this->_minutesId) ? $this->_relations['hasMany']['id'] : $this->_minutesId);
     $result = parent::fetchAll($where, $order, $count, $offset, $select, $join);
     // Integrate numbering
     $topicCount = 0;
     $topicSubCount = 0;
     foreach ($result as $item) {
         if (1 == $item->topicType) {
             $topicCount++;
             $topicSubCount = -1;
         }
         $topicSubCount++;
         $item->topicId = 1 == $item->topicType ? sprintf('%d', $topicCount) : sprintf('%d.%d', $topicCount, $topicSubCount);
     }
     return $result;
 }
Example #7
0
 /**
  * Customized version to calculate the status of a minutes item regardless of its saved database entry.
  *
  * @param string|array $where  Where clause.
  * @param string|array $order  Order by.
  * @param string|array $count  Limit query.
  * @param string|array $offset Query offset.
  * @param string       $select The comma-separated columns of the joined columns.
  * @param string       $join   The join statements.
  *
  * @return Zend_Db_Table_Rowset The rowset with the results.
  */
 public function fetchAll($where = null, $order = array('sort_order ASC', 'id DESC'), $count = null, $offset = null, $select = null, $join = null)
 {
     $result = parent::fetchAll($where, $order, $count, $offset, $select, $join);
     // Integrate numbering
     $topicCount = 0;
     $topicSubCount = 0;
     foreach ($result as $item) {
         if (1 == $item->topicType) {
             $topicCount++;
             $topicSubCount = -1;
         }
         $topicSubCount++;
         $item->topicId = 1 == $item->topicType ? sprintf('%d', $topicCount) : sprintf('%d.%d', $topicCount, $topicSubCount);
     }
     return $result;
 }
Example #8
0
 /**
  * Returns a set of records of the given active record that are associated
  * with the selected tree nodes.
  *
  * For example, you can get all todo recrods of projects in a given subtree.
  *
  * @param Phprojekt_ActiveRecord_Abstract $model  The active record used to get the data
  * @param int    $count  How many records should be retreived. null if unlimited. Optional.
  * @param int    $offset The initial offset. null for no offset. Optional.
  * @param string $where  A clause to narrow down matching objects. Optional.
  */
 public function getRecordsFor(Phprojekt_ActiveRecord_Abstract $model, $count = null, $offset = null, $where = null, $sort = null)
 {
     $projectIds = array_keys($this->_index);
     if (count($projectIds) == 0) {
         return array();
     } else {
         $database = $model->getAdapter();
         if (null !== $where) {
             $where .= " AND ";
         }
         $where .= $database->quoteInto('project_id IN (?)', $projectIds);
         return $model->fetchAll($where, $sort, $count, $offset);
     }
 }