コード例 #1
0
ファイル: solr.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * enqueueDB
  * 
  * @param string $type 
  * @param int $id 
  * @static
  * @access public
  * @return void
  */
 public static function enqueueDB($type = '', $ids = array(), $action = 'index')
 {
     if ($type != '' && !empty($ids)) {
         $db = App::get('db');
         $userID = User::getInstance()->get('uidNumber');
         $timestamp = Date::of()->toSql();
         if ($db->tableExists('#__search_queue') && count($ids) > 0) {
             $sql = "INSERT INTO #__search_queue (type, type_id, status, action, created_by, created) VALUES ";
             foreach ($ids as $key => $id) {
                 if (!is_array($id)) {
                     $sql .= "('" . $type . "'," . $id . ", 0, '" . $action . "', " . $userID . ", '{$timestamp}}'),";
                 }
             }
             $sql = rtrim($sql, ',');
             $sql .= ';';
             try {
                 $db->setQuery($sql);
                 $db->query();
                 return true;
             } catch (\Exception $e) {
                 //@FIXME: properly handle this error
                 ddie($e->getMessage());
             }
         } else {
             throw new \Hubzero\Exception\Exception('Queue table does not exist.');
         }
     }
 }
コード例 #2
0
ファイル: tickets.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * onIndex 
  * 
  * @param string $type
  * @param integer $id 
  * @param boolean $run 
  * @access public
  * @return void
  */
 public function onIndex($type, $id, $run = false)
 {
     if ($type == 'ticket') {
         if ($run === true) {
             // Establish a db connection
             $db = App::get('db');
             // Sanitize the string
             $id = \Hubzero\Utility\Sanitize::paranoid($id);
             // Get the record
             $sql = "SELECT * FROM #__support_tickets WHERE id={$id};";
             $row = $db->setQuery($sql)->query()->loadObject();
             ddie($row);
             // Get the name of the author
             $sql1 = "SELECT name FROM #__users WHERE id={$row->created_by};";
             $author = $db->setQuery($sql1)->query()->loadResult();
             // Get any tags
             $sql2 = "SELECT tag \n\t\t\t\t\tFROM #__tags\n\t\t\t\t\tLEFT JOIN #__tags_object\n\t\t\t\t\tON #__tags.id=#__tags_object.tagid\n\t\t\t\t\tWHERE #__tags_object.objectid = {$id} AND #__tags_object.tbl = 'blog';";
             $tags = $db->setQuery($sql2)->query()->loadColumn();
             // Determine the path
             $year = Date::of(strtotime($row->publish_up))->toLocal('Y');
             $month = Date::of(strtotime($row->publish_up))->toLocal('m');
             $alias = $row->alias;
             if ($row->scope == 'site') {
                 $path = '/blog/' . $year . '/' . $month . '/' . $alias;
             } elseif ($row->scope == 'member') {
                 $path = '/members/' . $row->scope_id . '/blog/' . $year . '/' . $month . '/' . $alias;
             } elseif ($row->scope == 'group') {
                 $group = Group::getInstance($row->scope_id);
                 // Make sure group is valid.
                 if (is_object($group)) {
                     $cn = $group->get('cn');
                     $path = '/groups/' . $cn . '/blog/' . $year . '/' . $month . '/' . $alias;
                 } else {
                     $path = '';
                 }
             }
             // Public condition
             if ($row->state == 1 && $row->access == 1) {
                 $access_level = 'public';
             } elseif ($row->state == 1 && $row->access == 2) {
                 $access_level = 'registered';
             } else {
                 $access_level = 'private';
             }
             if ($row->scope != 'group') {
                 $owner_type = 'user';
                 $owner = $row->created_by;
             } else {
                 $owner_type = 'group';
                 $owner = $row->scope_id;
             }
             // Get the title
             $title = $row->title;
             // Build the description, clean up text
             $content = preg_replace('/<[^>]*>/', ' ', $row->content);
             $content = preg_replace('/ {2,}/', ' ', $content);
             $description = \Hubzero\Utility\Sanitize::stripAll($content);
             // Create a record object
             $record = new \stdClass();
             $record->id = $type . '-' . $id;
             $record->hubtype = $type;
             $record->title = $title;
             $record->description = $description;
             $record->author = array($author);
             $record->tags = $tags;
             $record->path = $path;
             $record->access_level = $access_level;
             $record->owner = $owner;
             $record->owner_type = $owner_type;
             // Return the formatted record
             return $record;
         } else {
             $db = App::get('db');
             $sql = "SELECT id FROM #__blog_entries;";
             $ids = $db->setQuery($sql)->query()->loadColumn();
             return $ids;
         }
     }
 }