Example #1
0
 /**
  * load Load the data from the database
  * 
  * @access public
  * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function load()
 {
     if ($this->verifyId($this->mSampleId) || $this->verifyId($this->mContentId)) {
         // LibertyContent::load()assumes you have joined already, and will not execute any sql!
         // This is a significant performance optimization
         $lookupColumn = $this->verifyId($this->mSampleId) ? 'sample_id' : 'content_id';
         $bindVars = array();
         $selectSql = $joinSql = $whereSql = '';
         array_push($bindVars, $lookupId = @BitBase::verifyId($this->mSampleId) ? $this->mSampleId : $this->mContentId);
         $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
         $query = "\n\t\t\t\tSELECT sample.*, lc.*,\n\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name\n\t\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "sample_data` sample\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = sample.`content_id` ) {$joinSql}\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tWHERE sample.`{$lookupColumn}`=? {$whereSql}";
         $result = $this->mDb->query($query, $bindVars);
         if ($result && $result->numRows()) {
             $this->mInfo = $result->fields;
             $this->mContentId = $result->fields['content_id'];
             $this->mSampleId = $result->fields['sample_id'];
             $this->mInfo['creator'] = !empty($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user'];
             $this->mInfo['editor'] = !empty($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user'];
             $this->mInfo['display_name'] = BitUser::getTitleFromHash($this->mInfo);
             $this->mInfo['display_url'] = $this->getDisplayUrl();
             $this->mInfo['parsed_data'] = $this->parseData();
             LibertyMime::load();
         }
     }
     return count($this->mInfo);
 }
Example #2
0
 /**
  * load the pigeonhole
  * @param $pExtras boolean - if set to true, pigeonhole content is added as well
  * @return bool TRUE on success, FALSE if it's not valid
  * @access public
  **/
 function load($pExtras = FALSE, $pLoadAttachable = TRUE)
 {
     if (@BitBase::verifyId($this->mContentId) || @BitBase::verifyId($this->mStructureId)) {
         global $gBitSystem;
         $lookupColumn = @BitBase::verifyId($this->mContentId) ? 'lc.`content_id`' : 'ls.`structure_id`';
         $lookupId = @BitBase::verifyId($this->mContentId) ? $this->mContentId : $this->mStructureId;
         $query = "SELECT pig.*, ls.`root_structure_id`, ls.`parent_id`, lc.`title`, lc.`data`,\n\t\t\t\tlc.`user_id`, lc.`content_type_guid`, lc.`format_guid`,\n\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonholes` pig\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = pig.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "liberty_structures` ls ON ( ls.`structure_id` = pig.`structure_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON ( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tWHERE {$lookupColumn}=?";
         $result = $this->mDb->query($query, array($lookupId));
         if ($result && ($row = $result->fetchRow())) {
             $this->mInfo = $row;
             $this->mContentId = $row['content_id'];
             $this->mStructureId = $row['structure_id'];
             $this->mInfo['user'] = $row['creator_user'];
             $this->mInfo['real_name'] = isset($row['creator_real_name']) ? $row['creator_real_name'] : $row['creator_user'];
             $this->mInfo['display_name'] = BitUser::getTitleFromHash($this->mInfo);
             $this->mInfo['editor'] = isset($row['modifier_real_name']) ? $row['modifier_real_name'] : $row['modifier_user'];
             $this->mInfo['display_link'] = $this->getDisplayLink();
             $this->mInfo['display_url'] = $this->getDisplayUrl();
             $this->mInfo['parsed_data'] = $this->parseData($row);
         }
         if ($pLoadAttachable) {
             LibertyMime::load();
         }
         // if the content for the pigeonhole is requested, get it
         if ($pExtras) {
             $this->mInfo['path'] = $this->getPigeonholePath();
             $this->mInfo['display_path'] = $this->getDisplayPath($this->mInfo['path']);
             $memberHash = array('max_records' => -1);
             $this->mInfo['members'] = $this->getMemberList($memberHash);
             $this->mInfo['members_count'] = count($this->mInfo['members']);
         }
     }
     return count($this->mInfo);
 }
 /**
  * load Load the data from the database
  * 
  * @access public
  * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function load()
 {
     if ($this->verifyId($this->mEnergyMeasuresId) || $this->verifyId($this->mContentId)) {
         // LibertyContent::load()assumes you have joined already, and will not execute any sql!
         // This is a significant performance optimization
         $lookupColumn = $this->verifyId($this->mEnergyMeasuresId) ? 'energymeasure_id' : 'content_id';
         $bindVars = array();
         $selectSql = $joinSql = $whereSql = '';
         array_push($bindVars, $lookupId = @BitBase::verifyId($this->mEnergyMeasuresId) ? $this->mEnergyMeasuresId : $this->mContentId);
         $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
         $query = "\n\t\t\t\tSELECT energymeasures.*, lc.*,\n\t\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name,\n\t\t\t\t\tlfp.storage_path AS `image_attachment_path` \n\t\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "energymeasures_data` energymeasures\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = energymeasures.`content_id` ) \n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON( uuc.`user_id` = lc.`user_id` )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la ON( la.`content_id` = lc.`content_id` AND la.`is_primary` = 'y' )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` lfp ON( lfp.`file_id` = la.`foreign_id` )\n\t\t\t\t\t{$joinSql}\n\t\t\t\tWHERE energymeasures.`{$lookupColumn}`=? {$whereSql}";
         $result = $this->mDb->query($query, $bindVars);
         if ($result && $result->numRows()) {
             $this->mInfo = $result->fields;
             $this->mContentId = $result->fields['content_id'];
             $this->mEnergyMeasuresId = $result->fields['energymeasure_id'];
             $this->mInfo['creator'] = !empty($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user'];
             $this->mInfo['editor'] = !empty($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user'];
             $this->mInfo['display_name'] = BitUser::getTitleFromHash($this->mInfo);
             $this->mInfo['display_url'] = $this->getDisplayUrl();
             $this->mInfo['parsed_data'] = $this->parseData();
             $this->mInfo['thumbnail_urls'] = $this->getThumbnailUrls($this->mInfo);
             LibertyMime::load();
         }
     }
     return count($this->mInfo);
 }
Example #4
0
 /**
  * load Load the data from the database
  * 
  * @access public
  * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function load()
 {
     if ($this->verifyId($this->mTicketId) || $this->verifyId($this->mContentId)) {
         // LibertyContent::load()assumes you have joined already, and will not execute any sql!
         // This is a significant performance optimization
         $lookupColumn = $this->verifyId($this->mTicketId) ? 'ticket_id' : 'content_id';
         $bindVars = array();
         $selectSql = $joinSql = $whereSql = '';
         array_push($bindVars, $lookupId = @BitBase::verifyId($this->mTicketId) ? $this->mTicketId : $this->mContentId);
         $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
         $query = "\n\t\t\t\tSELECT t.*, lc.*,\n\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name,\n\t\t\t\tlcm.`title` AS milestone_title\n\t\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "tickets` t\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = t.`content_id` ) {$joinSql}\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON( uuc.`user_id` = lc.`user_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "liberty_content` lcm ON( lc.`content_id` = t.`milestone_id` )\n\t\t\t\tWHERE t.`{$lookupColumn}`=? {$whereSql}";
         $attrQuery = "SELECT ta.*, tf.`def_id`, tf.`field_id`, tf.`field_value`, td.`title` AS def_title\n                FROM `" . BIT_DB_PREFIX . "ticket_attributes` ta\n                    LEFT JOIN `" . BIT_DB_PREFIX . "ticket_field_values` tf ON( ta.`field_id` = tf.`field_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "ticket_field_defs` td ON( tf.`def_id` = td.`def_id` )\n                WHERE ta.`ticket_id`=?";
         $result = $this->mDb->query($query, $bindVars);
         if ($result && $result->numRows()) {
             $this->mInfo = $result->fields;
             $this->mContentId = $result->fields['content_id'];
             $this->mTicketId = $result->fields['ticket_id'];
             $this->mMilestone['milestone_id'] = $result->fields['milestone_id'];
             $this->mMilestone['title'] = $result->fields['milestone_title'];
             $this->mInfo['creator'] = !empty($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user'];
             $this->mInfo['editor'] = !empty($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user'];
             $this->mInfo['display_name'] = BitUser::getTitleFromHash($this->mInfo);
             $this->mInfo['display_url'] = $this->getDisplayUrl();
             $this->mInfo['parsed_data'] = $this->parseData();
             $attrResult = $this->mDb->query($attrQuery, array($this->mTicketId));
             while ($row = $attrResult->fetchRow()) {
                 $this->mAttributes[$row["def_id"]] = $row;
             }
             LibertyMime::load();
         }
     }
     return count($this->mInfo);
 }