events
[ class tree: events ] [ index: events ] [ all elements ]

Source for file BitEvents.php

Documentation is available at BitEvents.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  *
  5.  *  Class for representing an event. Plans are to support RFC2455 style repeating events with iCal input and output.
  6.  *  As well as supporting invites.
  7.  *
  8.  * @author nick <nick@overtsolutions.com>
  9.  * @package events
  10.  */
  11.  
  12. /**
  13.  * required setup
  14.  */
  15. require_onceLIBERTY_PKG_PATH.'LibertyMime.php' );
  16. include_onceKERNEL_PKG_PATH.'BitDate.php' );
  17.  
  18. /**
  19.  * This is used to uniquely identify the object
  20.  */
  21. define'BITEVENTS_CONTENT_TYPE_GUID''bitevents' );
  22.  
  23. /**
  24.  * @package events
  25.  */
  26. class BitEvents extends LibertyMime {
  27.     /**
  28.     * Primary key for our mythical Events class object & table
  29.     * @public
  30.     */
  31.     var $mEventsId;
  32.  
  33.     /**
  34.     * During initialisation, be sure to call our base constructors
  35.     **/
  36.  
  37.     function BitEvents$pEventsId=NULL$pContentId=NULL {
  38.         parent::__construct();
  39.         $this->mEventsId = $pEventsId;
  40.         $this->mContentId = $pContentId;
  41.         $this->mContentTypeGuid = BITEVENTS_CONTENT_TYPE_GUID;
  42.         $this->registerContentTypeBITEVENTS_CONTENT_TYPE_GUIDarray(
  43.             'content_type_guid' => BITEVENTS_CONTENT_TYPE_GUID,
  44.             'content_name' => 'Event',
  45.             'handler_class' => 'BitEvents',
  46.             'handler_package' => 'events',
  47.             'handler_file' => 'BitEvents.php',
  48.             'maintainer_url' => 'http://wired.st-and.ac.uk/~hash9/'
  49.         ) );
  50.  
  51.         $this->mDate new BitDate();
  52.         $this->mDate->get_display_offset();
  53.  
  54.         // Permission setup
  55.         $this->mViewContentPerm  = 'p_events_view';
  56.         $this->mCreateContentPerm  = 'p_events_create';
  57.         $this->mUpdateContentPerm  = 'p_events_update';
  58.         $this->mAdminContentPerm = 'p_events_admin';
  59.     }
  60.  
  61.     /**
  62.     * Load the data from the database
  63.     * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  64.     ***/
  65.     function load$pContentId NULL$pPluginParams NULL {
  66.         global $gBitSystem;
  67.         if$this->verifyId$this->mEventsId || $this->verifyId$this->mContentId ) ) {
  68.             // LibertyContent::load()assumes you have joined already, and will not execute any sql!
  69.             // This is a significant performance optimization
  70.             $lookupColumn $this->verifyId$this->mEventsId 'events_id' 'content_id';
  71.             $bindVars array()$selectSql ''$joinSql ''$whereSql '';
  72.             array_push$bindVars$lookupId @BitBase::verifyId$this->mEventsId )$this->mEventsId : $this->mContentId );
  73.             $this->getServicesSql'content_load_sql_function'$selectSql$joinSql$whereSql$bindVars );
  74.  
  75.             $query "SELECT e.*, et.`name` as `type_name`, lc.*, " .
  76.                 "uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name, " .
  77.                 "uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name " .
  78.                 "$selectSql .
  79.                 "FROM `".BIT_DB_PREFIX."events` e " .
  80.                 "LEFT JOIN `".BIT_DB_PREFIX."events_types` et ON (e.`type_id` = et.`type_id`)".
  81.                 "INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = e.`content_id` ) $joinSql.
  82.                 "LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )" .
  83.                 "LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON( uuc.`user_id` = lc.`user_id` )" .
  84.                 "WHERE e.`$lookupColumn`=? $whereSql";
  85.             $result $this->mDb->query$query$bindVars );
  86.  
  87.             if$result && $result->numRows() ) {
  88.                 $this->mInfo = $result->fields;
  89.                 $this->mContentId = $result->fields['content_id'];
  90.                 $this->mEventsId = $result->fields['events_id'];
  91.  
  92.                 $this->mInfo['creator'=isset$result->fields['creator_real_name')$result->fields['creator_real_name'$result->fields['creator_user');
  93.                 $this->mInfo['editor'=isset$result->fields['modifier_real_name')$result->fields['modifier_real_name'$result->fields['modifier_user');
  94.                 $this->mInfo['display_url'$this->getDisplayUrl();
  95.                 $this->mInfo['parsed_data'$this->parseData$this->mInfo['data']$this->mInfo['format_guid');
  96.  
  97.                 $prefChecks array('show_start_time''show_end_time');
  98.                 foreach ($prefChecks as $key => $var{
  99.                     if ($this->getPreference($var== 'on'{
  100.                         $this->mInfo[$var1;
  101.                     }
  102.                     else {
  103.                         $this->mInfo[$var0;
  104.                     }
  105.                 }
  106.  
  107.                 LibertyMime::load();
  108.             }
  109.         }
  110.         returncount$this->mInfo ) );
  111.     }
  112.  
  113.     function preview&$pParamHash {
  114.         global $gBitSmarty$gBitSystem;
  115.         $this->verify$pParamHash );
  116.         // This is stupid! verify does NOT work how it should.
  117.         // verify should call the super class verify at all levels.
  118.         LibertyMime::verify($pParamHash);
  119.         LibertyContent::verify($pParamHash);
  120.  
  121.         $this->mInfo = array_merge($pParamHash['events_store']$pParamHash['content_store']empty($pParamHash['events_prefs_store']array($pParamHash['events_prefs_store']);
  122.         $this->mInfo['data'$pParamHash['edit'];
  123.         $this->mInfo['parsed'$this->parseData($pParamHash['edit']empty($pParamHash['format_guid']$pParamHash['format_guid'$gBitSystem->getConfig('default_format'));
  124.  
  125.         $this->invokeServices'content_preview_function' );
  126.  
  127.         $gBitSmarty->assign('preview'true);
  128.  
  129.     }
  130.  
  131.     /**
  132.     * Any method named Store inherently implies data will be written to the database
  133.     * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  134.     *  This is the ONLY method that should be called in order to store( create or update )an events!
  135.     *  It is very smart and will figure out what to do for you. It should be considered a black box.
  136.     *
  137.     * @param array pParams hash of values that will be used to store the page
  138.     *
  139.     * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  140.     *
  141.     * @access public
  142.     ***/
  143.     function store&$pParamHash {
  144.         $this->mDb->StartTrans();
  145.         if$this->verify$pParamHash )&& LibertyMime::store$pParamHash ) ) {
  146.             $table BIT_DB_PREFIX."events";
  147.  
  148.             $prefChecks array('show_start_time''show_end_time');
  149.             foreach ($prefChecks as $var{
  150.                 if (isset($pParamHash['events_prefs_store'][$var])) {
  151.                     $this->storePreference($var$pParamHash['events_prefs_store'][$var]);
  152.                 }
  153.                 else {
  154.                     $this->storePreference($var);
  155.                 }
  156.             }
  157.  
  158.             if$this->mEventsId {
  159.                 $result $this->mDb->associateUpdate$table$pParamHash['events_store']array'events_id' => $pParamHash['events_id') );
  160.                 $this->updateEventsOn($pParamHash);
  161.             else {
  162.                 $pParamHash['events_store']['content_id'$pParamHash['content_id'];
  163.                 if@$this->verifyId$pParamHash['events_id') ) {
  164.                     // if pParamHash['events_id'] is set, some is requesting a particular events_id. Use with caution!
  165.                     $pParamHash['events_store']['events_id'$pParamHash['events_id'];
  166.                 else {
  167.                     $pParamHash['events_store']['events_id'$this->mDb->GenID'events_events_id_seq' );
  168.                 }
  169.                 $this->mEventsId = $pParamHash['events_store']['events_id'];
  170.  
  171.                 $result $this->mDb->associateInsert$table$pParamHash['events_store');
  172.                 $this->insertEventsOn($pParamHash);
  173.             }
  174.  
  175.             $this->mDb->CompleteTrans();
  176.             $this->load();
  177.         }
  178.         returncount$this->mErrors )== );
  179.     }
  180.  
  181.     function insertEventsOn($pParamHash{
  182.         // TODO: This needs to be expanded to support repeating events.
  183.         $storeHash array();
  184.         $storeHash['content_id'$pParamHash['content_id'];
  185.         $storeHash['event_on'$pParamHash['content_store']['event_time'];
  186.         $this->mDb->associateInsertBIT_DB_PREFIX."events_on"$storeHash );
  187.     }
  188.  
  189.     function updateEventsOn($pParamHash{
  190.         // TODO: needs to be made to handle repeating events stuff.
  191.         // This should load up the existing events_on, generate the array of times. Delete any events_on not in the new set.
  192.         // And then add any from the array of times that don't exist already.
  193.         $this->mDb->associateUpdateBIT_DB_PREFIX."events_on"array'event_on' => $pParamHash['event_time')array'content_id' => $pParamHash['content_id') );
  194.     }
  195.  
  196.     /**
  197.     * Make sure the data is safe to store
  198.     * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  199.     *  This function is responsible for data integrity and validation before any operations are performed with the $pParamHash
  200.     *  NOTE: This is a PRIVATE METHOD!!!! do not call outside this class, under penalty of death!
  201.     *
  202.     * @param array pParams reference to hash of values that will be used to store the page, they will be modified where necessary
  203.     *
  204.     * @return bool TRUE on success, FALSE if verify failed. If FALSE, $this->mErrors will have reason why
  205.     *
  206.     * @access private
  207.     ***/
  208.     function verify&$pParamHash {
  209.         global $gBitUser$gBitSystem;
  210.         // make sure we're all loaded up of we have a mEventsId
  211.         if$this->verifyId$this->mEventsId )/* && empty( $this->mInfo )*/ {
  212.             $this->load();
  213.         }
  214.  
  215.         if@$this->verifyId$this->mInfo['content_id') ) {
  216.             $pParamHash['content_id'$this->mInfo['content_id'];
  217.         }
  218.  
  219.         // It is possible a derived class set this to something different
  220.         if@$this->verifyId$pParamHash['content_type_guid') ) {
  221.             $pParamHash['content_type_guid'$this->mContentTypeGuid;
  222.         }
  223.  
  224.         if@$this->verifyId$pParamHash['content_id') ) {
  225.             $pParamHash['events_store']['content_id'$pParamHash['content_id'];
  226.         }
  227.  
  228.         if!empty$pParamHash['cost') ) {
  229.             $pParamHash['events_store']['cost'substrtrim($pParamHash['cost'])0160 );
  230.         }
  231.  
  232.         $prefChecks array('show_start_time''show_end_time');
  233.         foreach ($prefChecks as $var{
  234.             if (isset($pParamHash[$var])) {
  235.                 $pParamHash['events_prefs_store'][$var$pParamHash[$var];
  236.             }
  237.         }
  238.  
  239.         if !empty($pParamHash['frequency') ) {
  240.             $pParamHash['events_store']['frequency'$pParamHash['frequency'];
  241.         }
  242.         else {
  243.             $pParamHash['events_store']['frequency'0;
  244.         }
  245.  
  246.         if!empty$pParamHash['type_id'&& $pParamHash['type_id'){
  247.             $pParamHash['events_store']['type_id'$pParamHash['type_id'];
  248.         }
  249.         else {
  250.             $pParamHash['events_store']['type_id'NULL;
  251.         }
  252.  
  253.         if!empty$pParamHash['start_date']&& !empty($pParamHash['start_time']) ) {
  254.             if (isset($pParamHash['start_time']['Meridian'])) {
  255.                 $pParamHash['event_time'=
  256.                     $this->mDate->gmmktime(($pParamHash['start_time']['Meridian'== 'pm' ?
  257.                                   $pParamHash['start_time']['Hour'12 :
  258.                                   $pParamHash['start_time']['Hour']),
  259.                                  $pParamHash['start_time']['Minute'],
  260.                                  isset($pParamHash['start_time']['Second']?
  261.                                  $pParamHash['start_time']['Second'0,
  262.                                  $pParamHash['start_date']['Month'],
  263.                                  $pParamHash['start_date']['Day'],
  264.                                  $pParamHash['start_date']['Year']
  265.                                  );
  266.             }
  267.             else {
  268.                 $pParamHash['event_time'=
  269.                     $this->mDate->gmmktime($pParamHash['start_time']['Hour'],
  270.                                  $pParamHash['start_time']['Minute'],
  271.                                  isset($pParamHash['start_time']['Second']?
  272.                                  $pParamHash['start_time']['Second'0,
  273.                                  $pParamHash['start_date']['Month'],
  274.                                  $pParamHash['start_date']['Day'],
  275.                                  $pParamHash['start_date']['Year']
  276.                                  );
  277.             }
  278.         }
  279.  
  280.         if!empty($pParamHash['end_time']&& !empty($pParamHash['event_time']) ) {
  281.             if (empty($pParamHash['start_date'])) {
  282.                 $pParamHash['start_date']['Month'$this->mDate->strftime("%m"$pParamHash['event_time']true);
  283.                 $pParamHash['start_date']['Day'$this->mDate->strftime("%d"$pParamHash['event_time']true);
  284.                 $pParamHash['start_date']['Year'$this->mDate->strftime("%Y"$pParamHash['event_time']true);
  285.             }
  286.             if ((!isset($pParamHash['end_time']['Meridian']||
  287.                  ($pParamHash['end_time']['Meridian'== 'am' ||
  288.                   $pParamHash['end_time']['Meridian'== 'pm')) &&
  289.                 (isset($pParamHash['end_time']['Hour']&&
  290.                  is_numeric($pParamHash['end_time']['Hour'])) &&
  291.                 (!isset($pParamHash['end_time']['Minute']||
  292.                  is_numeric($pParamHash['end_time']['Minute']&&
  293.                  (!isset($pParamHash['end_time']['Second']||
  294.                   is_numeric($pParamHash['end_time']['Second'])))) {
  295.  
  296.                 if (isset($pParamHash['end_time']['Meridian'])) {
  297.                     $pParamHash['events_store']['end_time'=
  298.                       $this->mDate->gmmktime(($pParamHash['end_time']['Meridian'== 'pm' ?
  299.                                       $pParamHash['end_time']['Hour'12 :
  300.                                       $pParamHash['end_time']['Hour']),
  301.                                      $pParamHash['end_time']['Minute'],
  302.                                      isset($pParamHash['end_time']['Second']?
  303.                                      $pParamHash['end_time']['Second'0,
  304.                                      $pParamHash['start_date']['Month'],
  305.                                      $pParamHash['start_date']['Day'],
  306.                                      $pParamHash['start_date']['Year']
  307.                                      );
  308.                 }
  309.                 else {
  310.                     $pParamHash['events_store']['end_time'=
  311.                       $this->mDate->gmmktime($pParamHash['end_time']['Hour'],
  312.                                      $pParamHash['end_time']['Minute'],
  313.                                      isset($pParamHash['end_time']['Second']?
  314.                                      $pParamHash['end_time']['Second'0,
  315.                                      $pParamHash['start_date']['Month'],
  316.                                      $pParamHash['start_date']['Day'],
  317.                                      $pParamHash['start_date']['Year']
  318.                                      );
  319.                 }
  320.                 $pParamHash['events_store']['end_time'$this->mDate->getUTCFromDisplayDate($pParamHash['events_store']['end_time']);
  321.             }
  322.         }
  323.  
  324.         if!empty$pParamHash['event_time') ) {
  325.             $pParamHash['event_time'$this->mDate->getUTCFromDisplayDate$pParamHash['event_time']);
  326.         else if !empty$this->mInfo['event_time') ) {
  327.             $pParamHash['event_time'$this->mDate->getUTCFromDisplayDate$this->mInfo['event_time']);
  328.         else {
  329.             $pParamHash['event_time'$gBitSystem->getUTCTime();
  330.         }
  331.  
  332.         // check some lengths, if too long, then truncate
  333.         if$this->isValid(&& !empty$this->mInfo['description'&& empty$pParamHash['description') ) {
  334.             // someone has deleted the description, we need to null it out
  335.             $pParamHash['events_store']['description''';
  336.         else ifempty$pParamHash['description') ) {
  337.             unset$pParamHash['description');
  338.         else {
  339.             ifstrlen$pParamHash['description'160 ) ) {
  340.                 $this->mErrors['error']['Description is too long.';
  341.             }
  342.             else {
  343.                 $pParamHash['events_store']['description'substr$pParamHash['description']0160 );
  344.             }
  345.         }
  346.  
  347.         if!empty$pParamHash['data') ) {
  348.             $pParamHash['edit'$pParamHash['data'];
  349.         }
  350.  
  351.         // check for name issues, first truncate length if too long
  352.         if!empty$pParamHash['title') ) {
  353.             ifempty$this->mEventsId ) ) {
  354.                 ifempty$pParamHash['title') ) {
  355.                     $this->mErrors['title''You must enter a name for this page.';
  356.                 else {
  357.                     $pParamHash['content_store']['title'substr$pParamHash['title']0160 );
  358.                 }
  359.             else {
  360.                 $pParamHash['content_store']['title'=isset$pParamHash['title') )substr$pParamHash['title']0160 )'';
  361.             }
  362.         else ifempty$pParamHash['title') ) {
  363.             // no name specified
  364.             $this->mErrors['title''You must specify a name';
  365.         }
  366.  
  367.         returncount$this->mErrors )== );
  368.     }
  369.  
  370.     /**
  371.     * This function removes a events entry
  372.     **/
  373.  
  374.     function expunge({
  375.         $ret FALSE;
  376.         if$this->isValid() ) {
  377.             $this->mDb->StartTrans();
  378.             $query "DELETE FROM `".BIT_DB_PREFIX."events_on` WHERE `content_id` = ?";
  379.             $result $this->mDb->query$queryarray$this->mContentId ) );
  380.             $query "DELETE FROM `".BIT_DB_PREFIX."events_invites` WHERE `content_id` = ?";
  381.             $result $this->mDb->query$queryarray$this->mContentId ) );
  382.             $query "DELETE FROM `".BIT_DB_PREFIX."events` WHERE `content_id` = ?";
  383.             $result $this->mDb->query$queryarray$this->mContentId ) );
  384.             ifLibertyMime::expunge() ) {
  385.                 $ret TRUE;
  386.                 $this->mDb->CompleteTrans();
  387.             else {
  388.                 $this->mDb->RollbackTrans();
  389.             }
  390.         }
  391.         return $ret;
  392.     }
  393.  
  394.     /**
  395.     * Make sure events is loaded and valid
  396.     **/
  397.  
  398.     function isValid({
  399.         return$this->verifyId$this->mEventsId ) );
  400.     }
  401.  
  402.     /**
  403.      * Returns an assoicative array of event types
  404.      **/
  405.  
  406.     function loadEventTypes($pIncludeDesc false{
  407.         return $this->mDb->getAssoc("SELECT `type_id`, `name` ".($pIncludeDesc ', `description`' '')." FROM `".BIT_DB_PREFIX."events_types` ORDER BY `name`");
  408.     }
  409.  
  410.     /**
  411.      * Removes a given type
  412.      */
  413.     function expungeType($pTypeId{
  414.         if$this->verifyId$pTypeId ) ) {
  415.             $this->mDb->query"DELETE FROM `".BIT_DB_PREFIX."events_types` WHERE type_id = ?"array($pTypeId) );
  416.         }
  417.     }
  418.  
  419.     /**
  420.      * Create the given type.
  421.      */
  422.     function storeType($pId NULL$pName$pDescription NULL{
  423.         $pName substr($pName030);
  424.         if!empty($pDescription) ) {
  425.             if$pDescription == '' {
  426.                 $pDescription NULL;
  427.             }
  428.             else {
  429.                 $pDescription substr($pDescription0160);
  430.             }
  431.         }
  432.         if!empty($pName) ) {
  433.             $pName substr($pName030);
  434.         }
  435.         else {
  436.             // Probably should error out here
  437.             $pname '';
  438.         }
  439.  
  440.         ifempty($pId) ) {
  441.             $pId $this->mDb->GenID'events_types_id_seq' );
  442.             $this->mDb->query("INSERT INTO `".BIT_DB_PREFIX."events_types` (`type_id`, `name`, `description`) VALUES (?, ?, ?)"array($pId$pName$pDescription));
  443.         }
  444.         else {
  445.             $this->mDb->query("UPDATE `".BIT_DB_PREFIX."events_types` SET `name` = ?, `description` = ? WHERE `type_id` = ?"array($pName$pDescription$pId));
  446.         }
  447.     }
  448.  
  449.     /**
  450.     * This function generates a list of records from the liberty_content database for use in a list page
  451.     **/
  452.  
  453.     function getList&$pParamHash {
  454.         global $gBitSystem$gBitUser;
  455.  
  456.         if empty$pParamHash['sort_mode') ) {
  457.             if empty$_REQUEST["sort_mode") ) {
  458.                 $pParamHash['sort_mode''event_time_asc';
  459.             else {
  460.             $pParamHash['sort_mode'$_REQUEST['sort_mode'];
  461.             }
  462.         }
  463. // Hack until sort_mode can be filtered to acceptable values
  464.         $pParamHash['sort_mode''event_time_asc';
  465.         
  466.         LibertyContent::prepGetList$pParamHash );
  467.  
  468.         $selectSql '';
  469.         $joinSql '';
  470.         $whereSql '';
  471.         $bindVars array();
  472.         array_push$bindVars$this->mContentTypeGuid );
  473.         $this->getServicesSql'content_list_sql_function'$selectSql$joinSql$whereSql$bindVars );
  474.  
  475.         // this will set $find, $sort_mode, $max_records and $offset
  476.         extract$pParamHash );
  477.  
  478.         ifis_array$find ) ) {
  479.             // you can use an array of pages
  480.             $whereSql .= " AND lc.`title` IN( ".implode',',array_fill0,count$find ),'?' ) )." )";
  481.             $bindVars array_merge$bindVars$find );
  482.         else ifis_string$find ) ) {
  483.             // or a string
  484.             $whereSql .= " AND UPPER( lc.`title` )like ? ";
  485.             $bindVars['%' strtoupper$find )'%';
  486.         else if@$this->verifyId$pUserId ) ) {
  487.             // or a string
  488.             $whereSql .= " AND lc.`creator_user_id` = ? ";
  489.             $bindVars[array$pUserId );
  490.         }
  491.  
  492.         if (!empty($event_before)) {
  493.             $whereSql .= " AND lc.`event_time` <= ? ";
  494.             $bindVars[$event_before;
  495.         }
  496.  
  497.  
  498.         if (!empty($event_after)) {
  499.             $whereSql .= " AND lc.`event_time` > ? ";
  500.             $bindVars[$event_after;
  501.         }
  502.  
  503.         $query "SELECT e.*, et.`name` as `type_name`, lc.`title`, lc.`data`, lc.`modifier_user_id` AS `modifier_user_id`, lc.`user_id` AS `creator_user_id`,
  504.             lc.`last_modified` AS `last_modified`, lc.`event_time` AS `event_time`, lc.`format_guid`, lcps.`pref_value` AS `show_start_time`, lcpe.`pref_value` AS `show_end_time`,
  505.             la.`attachment_id` AS primary_attachment_id
  506.             $selectSql
  507.             FROM `".BIT_DB_PREFIX."events` e
  508.             LEFT JOIN `".BIT_DB_PREFIX."events_types` et ON (e.`type_id` = et.`type_id`)
  509.             INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = e.`content_id` )
  510.             LEFT JOIN `".BIT_DB_PREFIX."liberty_content_prefs` lcps ON (lc.`content_id` = lcps.`content_id` AND lcps.`pref_name` = 'show_start_time')
  511.             LEFT JOIN `".BIT_DB_PREFIX."liberty_attachments` la ON (lc.`content_id` = la.`content_id` AND la.`is_primary` = 'y')
  512.             LEFT JOIN `".BIT_DB_PREFIX."liberty_content_prefs` lcpe ON (lc.`content_id` = lcpe.`content_id` AND lcpe.`pref_name` = 'show_end_time')
  513.             $joinSql
  514.             WHERE lc.`content_type_guid` = ? $whereSql
  515.             ORDER BY ".$this->mDb->convertSortmode$sort_mode );
  516.         $query_cant "SELECT COUNT( * )
  517.                 FROM `".BIT_DB_PREFIX."events` e
  518.                 INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = e.`content_id` ) $joinSql
  519.                 WHERE lc.`content_type_guid` = ? $whereSql";
  520.         $result $this->mDb->query$query$bindVars$max_records$offset );
  521.         $ret array();
  522.         while$res $result->fetchRow() ) {
  523.             if (!empty($parse_split)) {
  524.                 $res array_merge($this->parseSplit($res)$res);
  525.             }
  526.             $res['display_url'$this->getDisplayUrl($res['events_id']$res);
  527.             $res['primary_attachment'LibertyMime::loadAttachment$res['primary_attachment_id');
  528.             $ret[$res;
  529.         }
  530.         $pParamHash["data"$ret;
  531.  
  532.         $pParamHash["cant"$this->mDb->getOne$query_cant$bindVars );
  533.  
  534.         LibertyContent::postGetList$pParamHash );
  535.         return $ret;
  536.     }
  537.  
  538.     /* Limits content status types for users who can not enter all status */
  539.     function getAvailableContentStatuses$pUserMinimum=-100$pUserMaximum=100 {
  540.         global $gBitSystem;
  541.         if ($gBitSystem->isFeatureActive('events_moderation')) {
  542.             return LibertyContent::getAvailableContentStatuses(-100,0);
  543.         }
  544.         return parent::getAvailableContentStatuses();
  545.     }
  546.  
  547.     /**
  548.     * Generates the URL to the article
  549.     * @return the link to the full article
  550.     */
  551.     public static function getDisplayUrlFromHash&$pParamHash {
  552.         global $gBitSystem;
  553.  
  554.         $ret NULL;
  555.  
  556.         if@BitBase::verifyId$pParamHash['event_id') ) {
  557.             if$gBitSystem->isFeatureActive'pretty_urls_extended' ) ) {
  558.                 // Not needed since it's a number:  $ret = EVENTS_PKG_URL."view/".$this->mEventsId;
  559.                 $ret EVENTS_PKG_URL.$pParamHash['event_id'];
  560.             else if$gBitSystem->isFeatureActive'pretty_urls' ) ) {
  561.                 $ret EVENTS_PKG_URL.$pParamHash['event_id'];
  562.             else {
  563.                 $ret EVENTS_PKG_URL."index.php?events_id=".$pParamHash['event_id'];
  564.             }
  565.         }
  566.  
  567.         return $ret;
  568.     }
  569.  
  570.     /**
  571.     * Function that returns link to display an image
  572.     * @return the url to display the gallery.
  573.     */
  574.     public function getDisplayUrl({
  575.         $info array'event_id' => $this->mEventsId );
  576.         return self::getDisplayUrlFromHash$info );
  577.     }
  578.  
  579.     function getRenderFile({
  580.         return EVENTS_PKG_PATH."display_events_inc.php";
  581.     }
  582.  
  583. }
  584.  
  585. function events_content_list_sql(&$pObject{
  586.     if ACTIVE_PACKAGE == 'events' {
  587.         $ret['select_sql'", eo.`event_on` ";
  588.         $ret['join_sql'" LEFT OUTER JOIN `".BIT_DB_PREFIX."events_on` eo ON (lc.`content_id` = eo.`content_id`) ";
  589.         return $ret;
  590.     }
  591. }
  592.  
  593. ?>

Documentation generated on Wed, 29 Jul 2015 13:55:51 +0000 by phpDocumentor 1.5.0-lsces