示例#1
0
 /**
  *  Remove record from table
  */
 public function actionRemoveHelper()
 {
     if (Yii::app()->request->isAjaxRequest) {
         if (!Yii::app()->user->hasState('calUserId')) {
             Yii::app()->end();
         }
         //$user_id = $_POST['ui'];
         $user_id = Yii::app()->user->getState('calUserId');
         $title = $_POST['title'];
         $criteria = new CDbCriteria();
         $criteria->condition = 'user_id=:user_id';
         $criteria->params = array(':user_id' => $user_id);
         $criteria->addSearchCondition('title', $title);
         $eventsHelper = EventsHelper::model()->find($criteria);
         $eventsHelper->delete();
         Yii::app()->end();
     }
 }
示例#2
0
 protected function renderContent()
 {
     $criteria = new CDbCriteria(array('condition' => 'user_id=' . $this->userId));
     $events = EventsHelper::model()->findAll($criteria);
     $this->render('eventHelper', array('eventsList' => $events, 'dialogMode' => $this->dialogMode));
 }
 * @link        http://joomlacode.org/gf/project/jevents
 */
/**
 * Library for Latest Events Module
 **/
// following line is to prevent direct access to this script via the url
defined('_VALID_MOS') or die('Restricted access');
// setup for all required function and classes
$file = mosMainFrame::getBasePath() . 'components/com_events/includes/modutils.php';
if (file_exists($file)) {
    include_once $file;
} else {
    die("Events Latest\n<br />This module needs the Events component");
}
// load language constants
EventsHelper::loadLanguage('modlatest');
if (!defined('EVENTS_LATEST_MODULE')) {
    define('EVENTS_LATEST_MODULE', 1);
    function JEventsLatestcmpByStartTime(&$a, &$b)
    {
        // this custom sort compare function compares the start times of events that are referenced by the a & b vars
        if ($a->publish_up == $b->publish_up) {
            return 0;
        }
        if (!isset($a->_startTime)) {
            $a->_startTime = mktime($a->hup, $a->minup, $a->sup);
        }
        if (!isset($b->_startTime)) {
            $b->_startTime = mktime($b->hup, $b->minup, $b->sup);
        }
        return $a->_startTime < $b->_startTime ? -1 : 1;
示例#4
0
 function displayCalendarMod($time, $linkString, &$day_name, $monthMustHaveEvent = false)
 {
     global $startday, $database, $timeWithOffset, $my, $modparams;
     $myItemid = findAppropriateMenuID($catidsOut, $modcatids, $catidList, $modparams);
     $gid = $my->gid;
     if (strlen($catidsOut) > 0) {
         $cat = "&amp;catids={$catidsOut}";
     } else {
         $cat = "";
     }
     $cal_year = date("Y", $time);
     $cal_month = date("m", $time);
     $calmonth = date("n", $time);
     $month_name = EventsHelper::getMonthName($cal_month);
     $to_day = date("Y-m-d", $timeWithOffset);
     $cal_prev_month = $cal_month - 1;
     $cal_prev_month_yy = $cal_year;
     $cal_next_month = $cal_month + 1;
     $cal_next_month_yy = $cal_year;
     $cal_mod_next_year = $cal_year + 1;
     $cal_mod_prev_year = $cal_year - 1;
     $content = '';
     // additional EBS
     if ($cal_prev_month == 0) {
         $cal_prev_month = 12;
         $cal_prev_month_yy = $cal_prev_month_yy - 1;
     }
     if ($cal_next_month == 13) {
         $cal_next_month = 1;
         $cal_next_month_yy = $cal_next_month_yy + 1;
     }
     if ($modparams->minical_showlink) {
         $content = '<table cellpadding="0" cellspacing="0" width="140" align="center" class="mod_events_monthyear">' . "\n" . '<tr >' . "\n";
         if ($modparams->minical_showlink == 1) {
             $link = 'index.php?option=com_events&amp;Itemid=' . $myItemid . $cat . '&amp;task=';
             if ($modparams->minical_prevyear) {
                 $seflinkPrevYear = sefRelToAbs($link . 'view_year' . '&amp;day=1&amp;month=' . $cal_month . '&amp;year=' . $cal_mod_prev_year . '&amp;mod_cal_year=' . $cal_mod_prev_year . '&amp;mod_cal_month=' . $cal_month);
                 $content .= '<td>';
                 $content .= '<a class="mod_events_link" href="' . $seflinkPrevYear . '" title="' . _CAL_LANG_CLICK_TOSWITCH_PY . '">&laquo;</a>' . "\n";
                 $content .= '</td>';
             }
             if ($modparams->minical_prevmonth) {
                 $seflinkPrevMon = sefRelToAbs($link . 'view_month' . '&amp;day=1&amp;month=' . $cal_prev_month . '&amp;year=' . $cal_prev_month_yy . '&amp;mod_cal_year=' . $cal_prev_month_yy . '&amp;mod_cal_month=' . $cal_prev_month);
                 $content .= '<td>';
                 $content .= '<a class="mod_events_link" href="' . $seflinkPrevMon . '" title="' . _CAL_LANG_CLICK_TOSWITCH_PM . '">&lt;</a>' . "\n";
                 $content .= '</td>';
             }
             if ($modparams->minical_actmonth == 1) {
                 // combination of actual month and year: view month
                 $seflinkActMonth = sefRelToAbs($link . 'view_month' . '&amp;month=' . $cal_month . '&amp;year=' . $cal_year);
                 $content .= '<td align="center">';
                 $content .= '<a class="mod_events_link" href="' . $seflinkActMonth . '" title="' . _CAL_LANG_CLICK_TOSWITCH_MON . '">' . $month_name . '</a>' . "\n";
                 if ($modparams->minical_actyear < 1) {
                     $content .= '</td>';
                 }
             } elseif ($modparams->minical_actmonth == 2) {
                 $content .= '<td align="center">';
                 $content .= $month_name . "\n";
                 if ($modparams->minical_actyear < 1) {
                     $content .= '</td>';
                 }
             }
             if ($modparams->minical_actyear == 1) {
                 // combination of actual month and year: view year
                 $seflinkActYear = sefRelToAbs($link . 'view_year' . '&amp;month=' . $cal_month . '&amp;year=' . $cal_year);
                 if ($modparams->minical_actmonth < 1) {
                     $content .= '<td align="center">';
                 }
                 $content .= '<a class="mod_events_link" href="' . $seflinkActYear . '" title="' . _CAL_LANG_CLICK_TOSWITCH_YEAR . '">' . $cal_year . '</a>' . "\n";
                 $content .= '</td>';
             } elseif ($modparams->minical_actyear == 2) {
                 if ($modparams->minical_actmonth < 1) {
                     $content .= '<td align="center">';
                 }
                 $content .= $cal_year . "\n";
                 $content .= '</td>';
             }
             if ($modparams->minical_nextmonth) {
                 $seflinkNextMon = sefRelToAbs($link . 'view_month' . '&amp;day=1&amp;month=' . $cal_next_month . '&amp;year=' . $cal_next_month_yy . '&amp;mod_cal_year=' . $cal_next_month_yy . '&amp;mod_cal_month=' . $cal_next_month);
                 $content .= '<td>';
                 $content .= '<a class="mod_events_link" href="' . $seflinkNextMon . '" title="' . _CAL_LANG_CLICK_TOSWITCH_NM . '">&gt;</a>' . "\n";
                 $content .= '</td>';
             }
             if ($modparams->minical_nextyear) {
                 $seflinkNextYear = sefRelToAbs($link . 'view_year' . '&amp;day=1&amp;month=' . $cal_month . '&amp;year=' . $cal_mod_next_year . '&amp;mod_cal_year=' . $cal_mod_next_year . '&amp;mod_cal_month=' . $cal_month);
                 $content .= '<td>';
                 $content .= '<a class="mod_events_link" href="' . $seflinkNextYear . '" title="' . _CAL_LANG_CLICK_TOSWITCH_NY . '">&raquo;</a>' . "\n";
                 $content .= '</td>';
             }
             // combination of actual month and year: view year & month [ mic: not used here ]
             // $seflinkActYM   = sefRelToAbs( $link . 'view_month' . '&amp;month=' . $cal_month
             // . '&amp;year=' . $cal_year );
         } else {
             // show only text
             $content .= '<td>';
             $content .= $month_name . ' ' . $cal_year;
             $content .= '</td>';
         }
         $content .= "</tr>\n" . "</table>\n";
     }
     $content .= '<table align="center" class="mod_events_table" cellspacing="0" cellpadding="2">' . "\n" . '<tr class="mod_events_dayname">' . "\n";
     // Days name rows
     for ($i = 0; $i < 7; $i++) {
         $content .= "<td class='mod_events_td_dayname'>" . $day_name[($i + $startday) % 7] . "</td>\n";
     }
     $content .= "</tr>\n";
     // dmcd May 7/04 fix to fill in end days out of month correctly
     $dayOfWeek = $startday;
     $start = (date("w", mktime(0, 0, 0, $cal_month, 1, $cal_year)) - $startday + 7) % 7;
     $d = date("t", mktime(0, 0, 0, $cal_month, 0, $cal_year)) - $start + 1;
     if ($start > 0) {
         $content .= "<tr>\n";
     }
     for ($a = $start; $a > 0; $a--) {
         $content .= "<td class='mod_events_td_dayoutofmonth'>" . $d++ . "</td>\n";
         $dayOfWeek++;
     }
     $monthHasEvent = false;
     $lastDayOfMonth = date("t", mktime(0, 0, 0, $cal_month, 1, $cal_year));
     /********** COPIED FROM EVENTS.PHP **********/
     $select_date = $cal_year . '-' . $cal_month . '-01 00:00:00';
     $select_date_fin = $cal_year . '-' . $cal_month . '-' . $lastDayOfMonth . ' 23:59:59';
     $query = "SELECT #__events.*" . "\n , YEAR(publish_up  ) as yup, MONTH(publish_up  ) as mup, DAYOFMONTH(publish_up  ) as dup" . "\n , YEAR(publish_down) as ydn, MONTH(publish_down) as mdn, DAYOFMONTH(publish_down) as ddn" . "\n , HOUR(publish_up  ) as hup, MINUTE(publish_up  ) as minup, SECOND(publish_up  ) as sup" . "\n , HOUR(publish_down) as hdn, MINUTE(publish_down) as mindn, SECOND(publish_down) as sdn" . "\n FROM #__events" . "\n WHERE #__events.catid IN(" . accessibleCategoryList($gid, $modcatids, $catidList) . ")" . "\n AND #__events.access <= {$gid}" . "\n AND (((publish_up >= '{$select_date}%' AND publish_up <= '{$select_date_fin}%')" . "\n OR (publish_down >= '{$select_date}%' AND publish_down <= '{$select_date_fin}%')" . "\n OR (publish_up >= '{$select_date}%' AND publish_down <= '{$select_date_fin}%')" . "\n OR (publish_up <= '{$select_date}%' AND publish_down >= '{$select_date_fin}%')" . "\n )" . "\n AND #__events.state = '1')" . "\n ORDER BY publish_up ASC";
     $database->setQuery($query);
     $rows = $database->loadObjectList();
     /********** END COPIED FROM EVENTS.PHP **********/
     $rowcount = count($rows);
     $repeatArray = array();
     for ($i = 0; $i < $rowcount; $i++) {
         // build array of dates for each event
         $repeatArray[$i] = mosEventRepeatArrayMonth($rows[$i], $cal_year, $cal_month);
     }
     for ($d = 1; $d <= $lastDayOfMonth; $d++) {
         // Note that if we are on the last day of the month and last day of week then we won't have
         // any out of month days so don't start a new row!
         if ((date('w', mktime(0, 0, 0, $cal_month, $d, $cal_year)) - $startday) % 7 == 0) {
             // && $d!=date( 't', mktime( 0, 0, 0, $cal_month, $d, $cal_year ))){
             $content .= "<tr>";
         }
         $do = $d < 10 ? "0{$d}" : "{$d}";
         $selected_date = "{$cal_year}-{$cal_month}-{$do}";
         $cellDate = mktime(0, 0, 0, $cal_month, $d, $cal_year);
         $mark_bold = '';
         $mark_close_bold = '';
         $class = $selected_date == $to_day ? 'mod_events_td_todaynoevents' : 'mod_events_td_daynoevents';
         $dayHasEvent = false;
         for ($r = 0; $r < $rowcount && !$dayHasEvent; $r++) {
             if (array_key_exists($cellDate, $repeatArray[$r])) {
                 $monthHasEvent = true;
                 $dayHasEvent = true;
                 $mark_bold = "<b>";
                 $mark_close_bold = "</b>";
                 $class = $selected_date == $to_day ? "mod_events_td_todaywithevents" : "mod_events_td_daywithevents";
                 break;
             }
         }
         $sefdaylink = sefRelToAbs("index.php?option=com_events&amp;task=view_day&amp;year=" . $cal_year . "&amp;month=" . $cal_month . "&amp;day=" . $do . "&amp;Itemid=" . $myItemid . $cat);
         $content .= "<td class='" . $class . "'><a class='mod_events_daylink' href='" . $sefdaylink . "' title='" . _CAL_LANG_CLICK_TOSWITCH_DAY . "'>" . $mark_bold . $d . $mark_close_bold . "</a></td>\n";
         // Check if Next week row
         // dmcd May 7/04 fix to fill in end days out of month correctly
         //if(((date("w",mktime(0,0,0,$cal_month,$d,$cal_year))-$startday+1)%7)==0) {
         if ((1 + $dayOfWeek++) % 7 == $startday && intval($d) != date('t', mktime(0, 0, 0, $cal_month, $d, $cal_year))) {
             $content .= "</tr>\n";
         }
     }
     // Days out of the month
     // dmcd May 7/04 fix to fill in end days out of month correctly
     //if(((date("w",mktime(0,0,0,$cal_month+1,1,$cal_year))-$startday)%7)<>1) {
     $d = 1;
     //    while(((date("w",mktime(0,0,0,($cal_month+1),$d,$cal_year))-$startday+1)%7)<>1) {
     while ($dayOfWeek++ % 7 != $startday) {
         $content .= '<td class="mod_events_td_dayoutofmonth">' . $d . "</td>\n";
         $d++;
     }
     $content .= '</tr></table>' . "\n";
     // Many people found this confusing! (geraint)
     /* just a textlink [mic] - if wanted just delete the remarks at cont[]
      * if remarks are deleted at content, the links will be displayed right after each months
      * otherwise with cont[] as 1 block after the last month
      */
     //$seflink = sefRelToAbs( 'index.php?option=com_events&amp;task=view_month&amp;Itemid=' . $myItemid
     //. '&amp;month=' . $cal_month . '&amp;year=' . $cal_year );
     //$content .= '<table width="140" align="center"><tr><td class="mod_events_thismonth" >' . "\n";
     //$content .= '<div align="center"><a class="mod_events_link" href="' . $seflink . '">'
     //. $linkString . '</a></div>' . "\n";
     //$cont[] .= '<div align="center"><a class="mod_events_link" href="' . $seflink . '">' . $linkString.'</a></div>'."\n";
     //$content .= '</td></tr>' . "\n";
     //$content .= '</table>' . "\n";
     /* end textlink */
     // Now check to see if this month needs to have at least 1 event in order to display
     if (!$monthMustHaveEvent || $monthHasEvent) {
         return $content;
     } else {
         return '';
     }
 }