Exemplo n.º 1
0
 public function delete($iId)
 {
     $this->database()->update($this->_sTable, array('parent_id' => 0), 'parent_id = ' . (int) $iId);
     $aEvents = $this->database()->select('m.event_id, m.user_id, m.image_path')->from(Phpfox::getT('event_category_data'), 'mcd')->join(Phpfox::getT('event'), 'm', 'm.event_id = mcd.event_id')->where('mcd.category_id = ' . (int) $iId)->execute('getRows');
     foreach ($aEvents as $aEvent) {
         Event_Service_Process::instance()->delete($aEvent['event_id'], $aEvent);
     }
     $this->database()->delete($this->_sTable, 'category_id = ' . (int) $iId);
     $this->cache()->remove('event', 'substr');
     return true;
 }
Exemplo n.º 2
0
 public function add()
 {
     /*
     @title 
     @info Post an event.
     @method POST
     @extra title=#{Title of the event|string|yes}&venue=#{Venue of where the event will take place|string|yes}&description=#{Information about the event|string|yes}&country_iso=#{Country ISO ID. Use [action]core.getCountries[/action]|string|no}&country_child_id=#{State/Province ID#. Use [action]core.getCountries[/action] to get the correct ID#|int|no}&postal_code=#{Postal code|int|no}&city=#{City|string|no}&address=#{Address|string|no}&start_hour=#{24-hour format of an hour of when the event starts with leading zeros|int|yes}&start_minute=#{Minutes with leading zeros of when the event starts|int|yes}&start_day=#{Day of the month of when the event starts, 2 digits with leading zeros|int|yes}&start_month=#{A full numeric representation of a month of when the event starts, 2 digits|int|yes}&start_year=#{A full numeric representation of a year of when the event starts, 4 digits|int|yes}&end_hour=#{24-hour format of an hour of when the event ends with leading zeros|int|yes}&end_minute=#{Minutes with leading zeros of when the event ends|int|yes}&end_day=#{Day of the month of when the event ends, 2 digits with leading zeros|int|yes}&end_month=#{A full numeric representation of the month when the event ends, 2 digits|int|yes}&end_year=#{A full numeric representation of a year of when the event ends, 4 digits|int|yes}
     */
     if ($this->_oApi->isAllowed('event.add_event') == false) {
         return $this->_oApi->error('event.add_event', 'Unable to add an event for this user.');
     }
     $aInsert = array('title' => $this->_oApi->get('title'), 'location' => $this->_oApi->get('venue'), 'country_iso' => $this->_oApi->get('country_iso'), 'country_child_id' => $this->_oApi->get('country_child_id'), 'postal_code' => $this->_oApi->get('postal_code'), 'city' => $this->_oApi->get('city'), 'address' => $this->_oApi->get('address'), 'description' => $this->_oApi->get('description'), 'start_hour' => $this->_oApi->get('start_hour'), 'start_minute' => $this->_oApi->get('start_minute'), 'start_month' => $this->_oApi->get('start_month'), 'start_day' => $this->_oApi->get('start_day'), 'start_year' => $this->_oApi->get('start_year'), 'end_hour' => $this->_oApi->get('end_hour'), 'end_minute' => $this->_oApi->get('end_minute'), 'end_month' => $this->_oApi->get('end_month'), 'end_day' => $this->_oApi->get('end_day'), 'end_year' => $this->_oApi->get('end_year'));
     $iId = Event_Service_Process::instance()->add($aInsert);
     if (!$iId) {
         return $this->_oApi->error('event.unable_to_add_blog', implode('', Phpfox_Error::get()));
     }
     $aRows = $this->get($iId);
     return $aRows[0];
 }
Exemplo n.º 3
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::getUserParam('event.can_access_event', true);
     $aParentModule = $this->getParam('aParentModule');
     if ($aParentModule === null && $this->request()->getInt('req2') > 0) {
         return Phpfox_Module::instance()->setController('event.view');
     }
     if (($sLegacyTitle = $this->request()->get('req2')) && !empty($sLegacyTitle)) {
         if ($this->request()->get('req3') != '') {
             $sLegacyTitle = $this->request()->get('req3');
         }
         $aLegacyItem = Phpfox::getService('core')->getLegacyItem(array('field' => array('category_id', 'name'), 'table' => 'event_category', 'redirect' => 'event.category', 'title' => $sLegacyTitle, 'search' => 'name_url'));
     }
     if (($iRedirectId = $this->request()->getInt('redirect')) && ($aEvent = Event_Service_Event::instance()->getEvent($iRedirectId, true)) && $aEvent['module_id'] != 'event' && Phpfox::hasCallback($aEvent['module_id'], 'getEventRedirect')) {
         if ($sForward = Phpfox::callback($aEvent['module_id'] . '.getEventRedirect', $aEvent['event_id'])) {
             Phpfox::getService('notification.process')->delete('event_invite', $aEvent['event_id'], Phpfox::getUserId());
             $this->url()->forward($sForward);
         }
     }
     if ($iDeleteId = $this->request()->getInt('delete')) {
         if ($mDeleteReturn = Event_Service_Process::instance()->delete($iDeleteId)) {
             if (is_bool($mDeleteReturn)) {
                 $this->url()->send('event', null, Phpfox::getPhrase('event.event_successfully_deleted'));
             } else {
                 $this->url()->forward($mDeleteReturn, Phpfox::getPhrase('event.event_successfully_deleted'));
             }
         }
     }
     if (($iRedirectId = $this->request()->getInt('redirect')) && ($aEvent = Event_Service_Event::instance()->getEvent($iRedirectId, true))) {
         Phpfox::getService('notification.process')->delete('event_invite', $aEvent['event_id'], Phpfox::getUserId());
         $this->url()->permalink('event', $aEvent['event_id'], $aEvent['title']);
     }
     $bIsUserProfile = false;
     if (defined('PHPFOX_IS_AJAX_CONTROLLER')) {
         $bIsUserProfile = true;
         $aUser = Phpfox::getService('user')->get($this->request()->get('profile_id'));
         $this->setParam('aUser', $aUser);
     }
     if (defined('PHPFOX_IS_USER_PROFILE')) {
         $bIsUserProfile = true;
         $aUser = $this->getParam('aUser');
     }
     $oServiceEventBrowse = Phpfox::getService('event.browse');
     $sCategory = null;
     $sView = $this->request()->get('view', false);
     $aCallback = $this->getParam('aCallback', false);
     $this->search()->set(array('type' => 'event', 'field' => 'm.event_id', 'search_tool' => array('default_when' => 'upcoming', 'when_field' => 'start_time', 'when_upcoming' => true, 'table_alias' => 'm', 'search' => array('action' => $aParentModule === null ? $bIsUserProfile === true ? $this->url()->makeUrl($aUser['user_name'], array('event', 'view' => $this->request()->get('view'))) : $this->url()->makeUrl('event', array('view' => $this->request()->get('view'))) : $aParentModule['url'] . 'event/view_' . $this->request()->get('view') . '/', 'default_value' => Phpfox::getPhrase('event.search_events'), 'name' => 'search', 'field' => 'm.title'), 'sort' => array('latest' => array('m.start_time', Phpfox::getPhrase('event.latest'), 'ASC'), 'most-liked' => array('m.total_like', Phpfox::getPhrase('event.most_liked')), 'most-talked' => array('m.total_comment', Phpfox::getPhrase('event.most_discussed'))), 'show' => array(12, 15, 18, 21))));
     $aBrowseParams = array('module_id' => 'event', 'alias' => 'm', 'field' => 'event_id', 'table' => Phpfox::getT('event'), 'hide_view' => array('pending', 'my'));
     switch ($sView) {
         case 'pending':
             if (Phpfox::getUserParam('event.can_approve_events')) {
                 $this->search()->setCondition('AND m.view_id = 1');
             }
             break;
         case 'my':
             Phpfox::isUser(true);
             $this->search()->setCondition('AND m.user_id = ' . Phpfox::getUserId());
             break;
         default:
             if ($bIsUserProfile) {
                 $this->search()->setCondition('AND m.view_id ' . ($aUser['user_id'] == Phpfox::getUserId() ? 'IN(0,2)' : '= 0') . ' AND m.module_id = "event" AND m.privacy IN(' . (Phpfox::getParam('core.section_privacy_item_browsing') ? '%PRIVACY%' : Phpfox::getService('core')->getForBrowse($aUser)) . ') AND m.user_id = ' . (int) $aUser['user_id']);
             } elseif ($aParentModule !== null) {
                 $this->search()->setCondition('AND m.view_id = 0 AND m.privacy IN(%PRIVACY%) AND m.module_id = \'' . Phpfox_Database::instance()->escape($aParentModule['module_id']) . '\' AND m.item_id = ' . (int) $aParentModule['item_id'] . '');
             } else {
                 switch ($sView) {
                     case 'attending':
                         $oServiceEventBrowse->attending(1);
                         break;
                     case 'may-attend':
                         $oServiceEventBrowse->attending(2);
                         break;
                     case 'not-attending':
                         $oServiceEventBrowse->attending(3);
                         break;
                     case 'invites':
                         $oServiceEventBrowse->attending(0);
                         break;
                 }
                 if ($sView == 'attending') {
                     $this->search()->setCondition('AND m.view_id = 0 AND m.privacy IN(%PRIVACY%)');
                 } else {
                     $this->search()->setCondition('AND m.view_id = 0 AND m.privacy IN(%PRIVACY%) AND m.item_id = ' . ($aCallback !== false ? (int) $aCallback['item'] : 0) . '');
                 }
                 if ($this->request()->getInt('user') && ($aUserSearch = Phpfox::getService('user')->getUser($this->request()->getInt('user')))) {
                     $this->search()->setCondition('AND m.user_id = ' . (int) $aUserSearch['user_id']);
                     $this->template()->setBreadcrumb($aUserSearch['full_name'] . '\'s Events', $this->url()->makeUrl('event', array('user' => $aUserSearch['user_id'])), true);
                 }
             }
             break;
     }
     if ($this->request()->getInt('sponsor') == 1) {
         $this->search()->setCondition('AND m.is_sponsor != 1');
         Phpfox::addMessage(Phpfox::getPhrase('event.sponsor_help'));
     }
     if ($this->request()->get('req2') == 'category') {
         $sCategory = $this->request()->getInt('req3');
         $this->search()->setCondition('AND mcd.category_id = ' . (int) $sCategory);
     }
     if ($sView == 'featured') {
         $this->search()->setCondition('AND m.is_featured = 1');
     }
     $this->setParam('sCategory', $sCategory);
     $oServiceEventBrowse->callback($aCallback)->category($sCategory);
     $this->search()->browse()->params($aBrowseParams)->execute();
     $aFilterMenu = array();
     $bSetFilterMenu = !defined('PHPFOX_IS_USER_PROFILE') && !defined('PHPFOX_IS_PAGES_VIEW');
     if ($sPlugin = Phpfox_Plugin::get('event.component_controller_index_set_filter_menu_1')) {
         eval($sPlugin);
         if (isset($mReturnFromPlugin)) {
             return $mReturnFromPlugin;
         }
     }
     if ($bSetFilterMenu) {
         $aFilterMenu = array(Phpfox::getPhrase('event.all_events') => '', Phpfox::getPhrase('event.my_events') => 'my');
         if (Phpfox::isModule('friend') && !Phpfox::getParam('core.friends_only_community')) {
             $aFilterMenu[Phpfox::getPhrase('event.friends_events')] = 'friend';
         }
         list($iTotalFeatured, $aFeatured) = Event_Service_Event::instance()->getFeatured();
         if ($iTotalFeatured) {
             $aFilterMenu[Phpfox::getPhrase('event.featured_events') . '<span class="pending">' . $iTotalFeatured . '</span>'] = 'featured';
         }
         if (Phpfox::getUserParam('event.can_approve_events')) {
             $iPendingTotal = Event_Service_Event::instance()->getPendingTotal();
             if ($iPendingTotal) {
                 $aFilterMenu[Phpfox::getPhrase('event.pending_events') . '<span class="pending">' . $iPendingTotal . '</span>'] = 'pending';
             }
         }
         $aFilterMenu[] = true;
         $aFilterMenu[Phpfox::getPhrase('event.events_i_m_attending')] = 'attending';
         $aFilterMenu[Phpfox::getPhrase('event.events_i_may_attend')] = 'may-attend';
         $aFilterMenu[Phpfox::getPhrase('event.events_i_m_not_attending')] = 'not-attending';
         $aFilterMenu[Phpfox::getPhrase('event.event_invites')] = 'invites';
         $this->template()->buildSectionMenu('event', $aFilterMenu);
     }
     $this->template()->setTitle($bIsUserProfile ? Phpfox::getPhrase('event.full_name_s_events', array('full_name' => $aUser['full_name'])) : Phpfox::getPhrase('event.events'))->setBreadcrumb(Phpfox::getPhrase('event.events'), $aCallback !== false ? $this->url()->makeUrl($aCallback['url_home'][0], array_merge($aCallback['url_home'][1], array('event'))) : ($bIsUserProfile ? $this->url()->makeUrl($aUser['user_name'], 'event') : $this->url()->makeUrl('event')))->setHeader('cache', array('country.js' => 'module_core', 'browse.css' => 'module_event', 'feed.js' => 'module_feed'))->assign(array('aEvents' => $this->search()->browse()->getRows(), 'sView' => $sView, 'aCallback' => $aCallback, 'sParentLink' => $aCallback !== false ? $aCallback['url_home'][0] . '.' . implode('.', $aCallback['url_home'][1]) . '.event' : 'event', 'sApproveLink' => $this->url()->makeUrl('event', array('view' => 'pending'))));
     if ($sCategory !== null) {
         $aCategories = Phpfox::getService('event.category')->getParentBreadcrumb($sCategory);
         $iCnt = 0;
         foreach ($aCategories as $aCategory) {
             $iCnt++;
             $this->template()->setTitle($aCategory[0]);
             if ($aCallback !== false) {
                 $sHomeUrl = '/' . Phpfox_Url::instance()->doRewrite($aCallback['url_home'][0]) . '/' . implode('/', $aCallback['url_home'][1]) . '/' . Phpfox_Url::instance()->doRewrite('event') . '/';
                 $aCategory[1] = preg_replace('/^http:\\/\\/(.*?)\\/' . Phpfox_Url::instance()->doRewrite('event') . '\\/(.*?)$/i', 'http://\\1' . $sHomeUrl . '\\2', $aCategory[1]);
             }
             $this->template()->setBreadcrumb($aCategory[0], $aCategory[1], empty($sView) ? true : false);
         }
     }
     if ($aCallback !== false) {
         $this->template()->rebuildMenu('event.index', $aCallback['url_home']);
     }
     Phpfox_Pager::instance()->set(array('page' => $this->search()->getPage(), 'size' => $this->search()->getDisplay(), 'count' => $this->search()->browse()->getCount()));
     $this->setParam('global_moderation', array('name' => 'event', 'ajax' => 'event.moderation', 'menu' => array(array('phrase' => Phpfox::getPhrase('event.delete'), 'action' => 'delete'), array('phrase' => Phpfox::getPhrase('event.approve'), 'action' => 'approve'))));
 }
Exemplo n.º 4
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::isUser(true);
     Phpfox::getUserParam('event.can_create_event', true);
     $bIsEdit = false;
     $bIsSetup = $this->request()->get('req4') == 'setup' ? true : false;
     $sAction = $this->request()->get('req3');
     $aCallback = false;
     $sModule = $this->request()->get('module', false);
     $iItem = $this->request()->getInt('item', false);
     $aEvent = false;
     if ($iEditId = $this->request()->get('id')) {
         if ($aEvent = Event_Service_Event::instance()->getForEdit($iEditId)) {
             $bIsEdit = true;
             $this->setParam('aEvent', $aEvent);
             $this->setParam(array('country_child_value' => $aEvent['country_iso'], 'country_child_id' => $aEvent['country_child_id']));
             $this->template()->setHeader(array('<script type="text/javascript">$Behavior.eventEditCategory = function(){  var aCategories = explode(\',\', \'' . $aEvent['categories'] . '\'); for (i in aCategories) { $(\'#js_mp_holder_\' + aCategories[i]).show(); $(\'#js_mp_category_item_\' + aCategories[i]).attr(\'selected\', true); } }</script>'))->assign(array('aForms' => $aEvent, 'aEvent' => $aEvent));
             if ($aEvent['module_id'] != 'event') {
                 $sModule = $aEvent['module_id'];
                 $iItem = $aEvent['item_id'];
             }
         }
     }
     if ($sModule && $iItem && Phpfox::hasCallback($sModule, 'viewEvent')) {
         $aCallback = Phpfox::callback($sModule . '.viewEvent', $iItem);
         $this->template()->setBreadcrumb($aCallback['breadcrumb_title'], $aCallback['breadcrumb_home']);
         $this->template()->setBreadcrumb($aCallback['title'], $aCallback['url_home']);
         if ($sModule == 'pages' && !Phpfox::getService('pages')->hasPerm($iItem, 'event.share_events')) {
             return Phpfox_Error::display(Phpfox::getPhrase('event.unable_to_view_this_item_due_to_privacy_settings'));
         }
     }
     $aValidation = array('title' => Phpfox::getPhrase('event.provide_a_name_for_this_event'), 'location' => Phpfox::getPhrase('event.provide_a_location_for_this_event'));
     $oValidator = Phpfox_Validator::instance()->set(array('sFormName' => 'js_event_form', 'aParams' => $aValidation));
     if ($aVals = $this->request()->get('val')) {
         if ($oValidator->isValid($aVals)) {
             if ($bIsEdit) {
                 if (Event_Service_Process::instance()->update($aEvent['event_id'], $aVals, $aEvent)) {
                     switch ($sAction) {
                         case 'customize':
                             $this->url()->send('event.add.invite.setup', array('id' => $aEvent['event_id']), Phpfox::getPhrase('event.successfully_added_a_photo_to_your_event'));
                             break;
                         default:
                             $this->url()->permalink('event', $aEvent['event_id'], $aEvent['title'], true, Phpfox::getPhrase('event.successfully_invited_guests_to_this_event'));
                             break;
                     }
                 } else {
                     $aVals['event_id'] = $aEvent['event_id'];
                     $this->template()->assign(array('aForms' => $aVals, 'aEvent' => $aVals));
                 }
             } else {
                 if (($iFlood = Phpfox::getUserParam('event.flood_control_events')) !== 0) {
                     $aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('event'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
                     // actually check if flooding
                     if (Phpfox::getLib('spam')->check($aFlood)) {
                         Phpfox_Error::set(Phpfox::getPhrase('event.you_are_creating_an_event_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime());
                     }
                 }
                 if (Phpfox_Error::isPassed()) {
                     if ($iId = Event_Service_Process::instance()->add($aVals, $aCallback !== false ? $sModule : 'event', $aCallback !== false ? $iItem : 0)) {
                         $aEvent = Event_Service_Event::instance()->getForEdit($iId);
                         $this->url()->permalink('event', $aEvent['event_id'], $aEvent['title'], true, Phpfox::getPhrase('event.event_successfully_added'));
                     }
                 }
             }
         }
         $sStep = isset($aVals['step']) ? $aVals['step'] : '';
         $sAction = isset($aVals['action']) ? $aVals['action'] : '';
         $this->template()->assign('aForms', $aVals);
     }
     if ($bIsEdit) {
         $aMenus = array('detail' => Phpfox::getPhrase('event.event_details'), 'customize' => 'Banner', 'invite' => Phpfox::getPhrase('event.invite_guests'));
         if (!$bIsSetup) {
             $aMenus['manage'] = Phpfox::getPhrase('event.manage_guest_list');
             // $aMenus['email'] = Phpfox::getPhrase('event.mass_email');
         }
         $this->template()->buildPageMenu('js_event_block', $aMenus, array('link' => $this->url()->permalink('event', $aEvent['event_id'], $aEvent['title']), 'phrase' => Phpfox::getPhrase('event.view_this_event')));
     }
     $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('event.managing_event') . ': ' . $aEvent['title'] : Phpfox::getPhrase('event.create_an_event'))->setFullSite()->setBreadcrumb(Phpfox::getPhrase('event.events'), $aCallback === false ? $this->url()->makeUrl('event') : $this->url()->makeUrl($aCallback['url_home_pages']))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('event.managing_event') . ': ' . $aEvent['title'] : Phpfox::getPhrase('event.create_new_event'), $bIsEdit ? $this->url()->makeUrl('event.add', array('id' => $aEvent['event_id'])) : $this->url()->makeUrl('event.add'), true)->setEditor()->setPhrase(array('core.select_a_file_to_upload'))->setHeader('cache', array('add.js' => 'module_event', 'pager.css' => 'style_css', 'progress.js' => 'static_script', 'country.js' => 'module_core'))->setHeader(array('<script type="text/javascript">$Behavior.eventProgressBarSettings = function(){ if ($Core.exists(\'#js_event_block_customize_holder\')) { oProgressBar = {holder: \'#js_event_block_customize_holder\', progress_id: \'#js_progress_bar\', uploader: \'#js_progress_uploader\', add_more: false, max_upload: 1, total: 1, frame_id: \'js_upload_frame\', file_id: \'image\'}; $Core.progressBarInit(); } }</script>'))->assign(array('sCreateJs' => $oValidator->createJS(), 'sGetJsForm' => $oValidator->getJsForm(false), 'bIsEdit' => $bIsEdit, 'bIsSetup' => $bIsSetup, 'sCategories' => Phpfox::getService('event.category')->get(), 'sModule' => $aCallback !== false ? $sModule : '', 'iItem' => $aCallback !== false ? $iItem : '', 'aCallback' => $aCallback, 'iMaxFileSize' => Phpfox::getUserParam('event.max_upload_size_event') === 0 ? null : Phpfox::getLib('phpfox.file')->filesize(Phpfox::getUserParam('event.max_upload_size_event') / 1024 * 1048576), 'bCanSendEmails' => $bIsEdit ? Event_Service_Event::instance()->canSendEmails($aEvent['event_id']) : false, 'iCanSendEmailsTime' => $bIsEdit ? Event_Service_Event::instance()->getTimeLeft($aEvent['event_id']) : false, 'sJsEventAddCommand' => isset($aEvent['event_id']) ? "if (confirm('" . Phpfox::getPhrase('event.are_you_sure', array('phpfox_squote' => true)) . "')) { \$('#js_submit_upload_image').show(); \$('#js_event_upload_image').show(); \$('#js_event_current_image').remove(); \$.ajaxCall('event.deleteImage', 'id={$aEvent['event_id']}'); } return false;" : '', 'sTimeSeparator' => Phpfox::getPhrase('event.time_separator')));
 }
Exemplo n.º 5
0
 public function removeInvite()
 {
     Event_Service_Process::instance()->removeInvite($this->get('id'));
 }
Exemplo n.º 6
0
 /**
  * Action to take when user cancelled their account
  * @param int $iUser
  */
 public function onDeleteUser($iUser)
 {
     $aEvents = $this->database()->select('event_id')->from($this->_sTable)->where('user_id = ' . (int) $iUser)->execute('getSlaveRows');
     foreach ($aEvents as $aEvent) {
         Event_Service_Process::instance()->delete($aEvent['event_id']);
     }
 }