/** * Load a single album from database. This is having all data in $this object. * @access private */ public function load($collection_id) { Logger::log("Enter: Album::load() "); if ($this->album_type == 0) { $sql = "SELECT album_type_id FROM {contentcollections_albumtype} WHERE contentcollection_id = ? "; $data = array($collection_id); $res = Dal::query($sql, $data); if ($res->numRows()) { $row = $res->fetchRow(DB_FETCHMODE_OBJECT); $this->album_type = $row->album_type_id; } else { Logger::log("Throwing Exception CONTENT_COLLECTION_NOT_FOUND", LOGGER_ERROR); throw new CNException(CONTENT_COLLECTION_NOT_FOUND, "This album does not exist"); } } parent::load($collection_id); Logger::log("Exit: Album::load() "); return; }
/** * load collection_id * @access private * @param int content_id */ public function load($collection_id) { Logger::log("Enter: Group::load() | Args: \$collection_id = {$collection_id}"); parent::load($collection_id); $res = Dal::query("SELECT * FROM {groups} WHERE group_id = ?", array($collection_id)); if ($res->numRows()) { $row = $res->fetchRow(DB_FETCHMODE_OBJECT); $this->access_type = $row->access_type; $this->reg_type = $row->reg_type; $this->is_moderated = $row->is_moderated; $this->category_id = $row->category_id; $this->header_image = $row->header_image; $this->header_image_action = $row->header_image_action; $this->display_header_image = $row->display_header_image; $Category = new Category(); $Category->category_id = $this->category_id; $Category->load($Category->category_id); $this->category_name = $Category->name; } else { Logger::log("Thowing Exception CONTENT_NOT_FOUND"); throw new PAException(CONTENT_NOT_FOUND, "No group matched the provided ID"); } $res = Dal::query("SELECT * FROM {groups_users} WHERE group_id = ? AND (user_type =? OR user_type = ? )", array($collection_id, MODERATOR, OWNER)); while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { // if users is a moderator or owner $this->moderators[] = $row['user_id']; } Logger::log("Exit: Group::load()"); }
/** * loads array of all content, that are supposed to be moderated * for network operator control, network content management * @access public * @param array params * @param array conditions * @return array content */ public static function load_all_content_for_moderation($params = NULL, $conditions = NULL) { Logger::log("Enter: Content::load_all_content_for_moderation() | Args: \$params = {$params}, \$conditions = {$conditions}"); $sql = "SELECT CT.name AS content_name, C.content_id, C.collection_id, C.title, C.body, C.type, C.author_id, C.changed, C.created, C.is_active FROM {contents} AS C, {content_types} AS CT WHERE 1 AND CT.type_id = C.type"; if (is_array($conditions)) { foreach ($conditions as $field_name => $field_value) { $sql = $sql . ' AND ' . $field_name . ' = ' . $field_value; } } //paging variables if set $sort_by = $params['sort_by'] ? $params['sort_by'] : 'created'; $direction = $params['direction'] ? $params['direction'] : 'DESC'; $order_by = ' ORDER BY ' . $sort_by . ' ' . $direction; if ($params['page'] && $params['show'] && !$params['cnt']) { $start = ($params['page'] - 1) * $params['show']; $limit = ' LIMIT ' . $start . ',' . $params['show']; } else { $limit = ""; } $sql = $sql . $order_by . $limit; $res = Dal::query($sql); if ($params['cnt']) { if ($res->numRows() > 0) { return $res->numRows(); } } // preparing array, that is to be returned if ($res->numRows()) { $i = 0; while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { try { $author = new User(); $author->load((int) $row['author_id']); if ($row['collection_id'] != -1) { $var = new ContentCollection(); $var->load((int) $row['collection_id']); $collection['title'] = $var->title; $collection['type'] = $var->type; } else { $collection = array(); } $content_data[$i] = array('content_id' => $row['content_id'], 'title' => $row['title'], 'body' => $row['body'], 'author_id' => $row['author_id'], 'type' => $row['content_name'], 'changed' => $row['changed'], 'created' => date("j M Y H:i:s", $row['created']), 'type_name' => $row['name'], 'author_name' => $author->login_name, 'content_type_id' => $row['type'], 'parent_info' => $collection, 'is_active' => $row['is_active']); $i++; } catch (PAException $e) { // } } } Logger::log("Exit: Content::load_all_content_for_moderation()"); return $content_data; }
/** * load collection_id * @access private * @param int content_id */ public function load($collection_id) { Logger::log("Enter: Group::load() | Args: \$collection_id = {$collection_id}"); parent::load($collection_id); $res = Dal::query("SELECT * FROM {groups} WHERE group_id = ?", array($collection_id)); if ($res->numRows()) { $row = $res->fetchRow(DB_FETCHMODE_OBJECT); foreach ($row as $key => $v) { $this->{$key} = $v; } $Category = new Category(); $Category->category_id = $this->category_id; $Category->load($Category->category_id); $this->category_name = $Category->name; } else { Logger::log("Thowing Exception CONTENT_NOT_FOUND"); throw new PAException(CONTENT_NOT_FOUND, "No group matched the provided ID"); } if ($oid = Group::get_owner_id((int) $collection_id)) { $this->owner_id = $oid; } else { $this->owner_id = $this->author_id; } $res = Dal::query("SELECT * FROM {groups_users} WHERE group_id = ? AND (user_type =? OR user_type = ? )", array($collection_id, MODERATOR, OWNER)); while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { // if users is a moderator or owner $this->moderators[] = $row['user_id']; } Logger::log("Exit: Group::load()"); }