function execute()
 {
     global $wgRequest, $wgOut, $wgUser, $wgArticle;
     $sitting_of = $wgRequest->getVal('sitting_of');
     $session_number = $wgRequest->getVal('session_number');
     $sitting_start_date_time = $wgRequest->getVal('sitting_start_date_and_time');
     $sitting_end_date_time = $wgRequest->getVal('sitting_end_date_and_time');
     $sitting_session_number = $wgRequest->getVal('sitting_session_number');
     $wpEditToken = $wgRequest->getVal('wpEditToken');
     $sitting_desc = $wgRequest->getVal('sitting_desc');
     $sitting_start_date = substr($sitting_start_date_time, 0, strpos($sitting_start_date_time, ' '));
     $sitting_start_time = substr($sitting_start_date_time, strpos($sitting_start_date_time, ' ') + 1);
     $sitting_end_date = substr($sitting_end_date_time, 0, strpos($sitting_end_date_time, ' '));
     $sitting_end_time = substr($sitting_end_date_time, strpos($sitting_end_date_time, ' ') + 1);
     $sitting_name = $sitting_of . '-' . $sitting_start_date;
     //$sitting_of.'-'.$sitting_start_date_time.'-'
     $title = Title::newFromText($sitting_name, MV_NS_SITTING);
     $wgArticle = new Article($title);
     $wgArticle->doEdit($sitting_desc, wfMsg('mv_summary_add_sitting'));
     $dbkey = $title->getDBKey();
     $sitting = new MV_Sitting(array('name' => $dbkey, 'start_date' => $sitting_start_date, 'start_time' => $sitting_start_time, 'end_date' => $sitting_end_date, 'end_time' => $sitting_end_time));
     //$sitting->db_load_sitting();
     //$sitting->db_load_streams();
     if ($sitting->insertSitting()) {
         if ($wgArticle->exists()) {
             $wgOut->redirect($title->getLocalURL("action=staff"));
         } else {
             $html .= 'Article ' . $sitting_name . ' does not exist';
             $wgOut->addHtml($html);
         }
     } else {
         $WgOut->addHTML('Error: Duplicate Sitting Name?');
     }
 }
 function add_sitting()
 {
     $out = '';
     //get the stream pointer
     $sitting = new MV_Sitting(array('name' => $this->sitting_name));
     //if the stream is inserted procced with page insertion
     if ($sitting->insertSitting()) {
         global $wgUser;
         $sk = $wgUser->getSkin();
         //insert page
         $sittingTitle = Title::newFromText($this->sitting_name, MV_NS_SITTING);
         $wgArticle = new Article($sittingTitle);
         $success = $wgArticle->doEdit($this->sitting_desc, wfMsg('mv_summary_add_sitting'));
         if ($success) {
             //stream inserted succesfully report to output
             $sittingLink = $sk->makeLinkObj($sittingTitle, $this->sitting_name);
             $out = 'sitting ' . $sittingLink . ' added';
         } else {
             $out = wfMsg('mv_error_sitting_insert');
         }
     }
     return $out;
 }
 function execute()
 {
     global $wgRequest, $wgOut, $wgUser, $mvSitting_name, $mvgIP, $wgJsMimeType, $mvgScriptPath, $wgArticle, $sittingTypesTable;
     $sitting_of = $wgRequest->getVal('sitting_of');
     $session_number = $wgRequest->getVal('session_number');
     $sitting_start_date_time = $wgRequest->getVal('sitting_start_date_and_time');
     $sitting_end_date_time = $wgRequest->getVal('sitting_end_time');
     $sitting_session_number = $wgRequest->getVal('sitting_session_number');
     $wpEditToken = $wgRequest->getVal('wpEditToken');
     $sitting_desc = $wgRequest->getVal('sitting_desc');
     //$sitting_of.'-'.$sitting_start_date_time.'-'
     if ($sitting_of != '') {
         $sitting_name = $sitting_of . '-' . $sitting_start_date_time;
         $title = Title::newFromText($sitting_name, MV_NS_SITTING);
         $wgArticle = new Article($title);
         $wgArticle->doEdit($sitting_desc, wfMsg('mv_summary_add_sitting'));
         $dbkey = $title->getDBKey();
         $sitting = new MV_Sitting(array('name' => $dbkey));
         //$sitting->db_load_sitting();
         //$sitting->db_load_streams();
         $sitting->insertSitting();
         if ($wgArticle->exists()) {
             $wgOut->redirect($title->getLocalURL("action=staff"));
         } else {
             $html .= 'Article ' . $sitting_name . ' does not exist';
             $wgOut->addHtml($html);
         }
     }
     $html = '';
     $title_str = $wgRequest->getVal('title');
     $wgOut->addScript('<script type="text/javascript">/*<![CDATA[*/' . "var mvgScriptPath = '{$mvgScriptPath}';/*]]>*/</script>'" . "\n");
     $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$mvgScriptPath}/skins/dhtmlgoodies_calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js\"></script>");
     $wgOut->addStyle("dhtmlgoodies_calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css?random=20060118");
     if ($this->sitting_desc == '') {
         $desTitle = Title::makeTitle(MV_NS_SITTING, $this->sitting_name);
         //grab the article text:
         $curRevision = Revision::newFromTitle($desTitle);
         if ($curRevision) {
             $this->stream_desc = $curRevision->getText();
         }
     }
     if ($this->sitting_name == '') {
         //default page request
         $parts = split('/', $title_str);
         if (count($parts) >= 2) {
             //means we can use part 1 as a sitting name:
             $this->sitting_name = $parts[1];
         }
     } else {
         //output add_ status to html
         $html .= $this->add_sitting();
     }
     $this->check_permissions();
     if (count($this->_allowedSittingTypeArray) == 0) {
         //break out user lacks permissions to add anything
         $html .= wfMsg('add_sitting_permission');
         $wgOut->addHTML($html);
         return;
     }
     //output the add sitting form
     $spectitle = Title::makeTitle(NS_SPECIAL, 'Mv_add_edit_sitting');
     $docutitle = Title::newFromText(wfMsg('mv_add_sitting'), NS_HELP);
     if ($this->mode == 'edit') {
         $mvSittingTitle = Title::makeTitle(MV_NS_SITTING, $this->sitting_name);
         if ($mvSittingTitle->exists()) {
             $sk = $wgUser->getSkin();
             $sittingLink = $sk->makeLinkObj($mvSittingTitle, $this->sitting_name);
             $html .= wfMsg('mv_edit_sitting_docu', $sittingLink);
         }
     } else {
         $html .= wfMsg('mv_add_sitting_docu', $docutitle->getFullURL()) . "\n";
     }
     $html .= '<form name="add_sitting" action="' . $spectitle->escapeLocalURL() . '" method="post" enctype="multipart/form-data">';
     $html .= '<fieldset><legend>' . wfMsg('mv_add_sitting') . '</legend>' . "\n" . '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '"/>';
     $html .= '<table width="600" border="0">';
     $html .= '<tr>';
     $html .= '<td  width="500">';
     $html .= '<i>' . wfMsg('mv_label_sitting_of') . "</i>:";
     $html .= '</td>';
     $html .= '<td>';
     $html .= '<select name="sitting_of">';
     $dbr = wfGetDB(DB_SLAVE);
     $result = $dbr->select($sittingTypesTable, '*');
     while ($row = $dbr->fetchobject($result)) {
         $html .= "<option value=\"{$row->type}\">{$row->type}</option>";
     }
     $html .= '</select></td>';
     $html .= '</tr>' . "\n";
     $html .= '<tr>';
     $html .= '<td width="140">';
     $html .= '<i>' . wfMsg('mv_label_sitting_start_date') . "(YYYY-MM-DD)</i>:";
     $html .= '</td><td>';
     //$html.= '<input type="text" name="sitting_start_date_and_time" value="" size="30" maxlength="1024"><br />' . "\n";
     $html .= '<input type="text" value="2008/07/24 14:00" readonly name="sitting_start_date_and_time" onchange="document.add_sitting.sitting_end_date_and_time.value=this.value"><input type="button" value="Cal" onclick="displayCalendar(document.add_sitting.sitting_start_date_and_time,\'yyyy-mm-dd hh:ii\',this, true)"><div id="cal1"></div>';
     $html .= '</td>';
     /*
     $html.='<td>';
     $html.='Time</td><td><select name="start_hour">';
     for ($i=1; $i<=12; $i++)
     {
     	$html.='<option value='.$i.'>'.$i.'</option>';
     }
     $html.='</select>';	
     $html.='</td><td>';
     $html.='<select name="start_min">';
     for ($i=0; $i<=11; $i++)
     {
     	$j = $i * 5;	
     	$html.='<option value='.$j.'>'.$j.'</option>';
     }
     $html.='</select>';
     $html.='</td>';	
     $html.='<td>';	
     $html.='<select name="start_am_pm">';
     $html.='<option value="am">am</option>';
     $html.='<option value="pm">pm</option>';
     $html .= '</select>';
     $html.='</td>';	
     */
     $html .= '</tr>' . "\n";
     $html .= '<td width="140">';
     $html .= '<i>' . wfMsg('mv_label_sitting_end_date') . "(YYYY-MM-DD)</i>:";
     $html .= '</td><td>';
     //$html.= '<input type="text" name="sitting_end_date_and_time" value="" size="30" maxlength="1024"><br />' . "\n";
     $html .= '<input type="text" value="2008/07/24 14:00" readonly name="sitting_end_date_and_time"><input type="button" value="Cal" onclick="displayCalendar(document.add_sitting.sitting_end_date_and_time,\'yyyy-mm-dd hh:ii\',this, true)"><div id="cal2"></div>';
     //$html.='<div id="select-wrapper"><input type="text" id="date-sel2-dd" name="date-sel2-dd"/>';
     //$html.='<input type="text"id="date-sel2-mm" name="date-sel2-mm"/>';
     //$html.='<input type="text" class="w3em highlight-days-67 disable-days-12 split-date no-transparency" id="date-sel2" name="date-sel2" />
     //</div>';
     $html .= '</td>';
     /*
     		$html.='<td>';
     		$html.='Time</td><td><select name=end_hour>';
     		for ($i=1; $i<=12; $i++)
     		{
     			$html.='<option value='.$i.'>'.$i.'</option>';
     		}
     		$html.='</select>';
     		$html.='</td><td>';	
     		$html.='<select name="end_min">';
     		for ($i=0; $i<=11; $i++)
     		{
     			$j = $i * 5;	
     			$html.='<option value='.$j.'>'.$j.'</option>';
     		}
     	
     		$html.='</td>';	
     			$html.='</select>';
     		$html.='<td>';	
     		$html.='<select name="start_am_pm">';
     		$html.='<option value="am">am</option>';
     		$html.='<option value="pm">pm</option>';
     		$html .= '</select>';
     		$html.='</td>';		
     */
     $html .= '</tr>' . "\n";
     $html .= '<td  width="140">';
     $html .= '<i>' . wfMsg('mv_label_sitting_session_number') . "</i>:";
     $html .= '</td><td>';
     $html .= '<input type="text" name="sitting_session_number" value="" size="30" maxlength="1024"><br />' . "\n";
     $html .= '</td>';
     $html .= '</tr>' . "\n";
     $html .= '<td  width="140">';
     $html .= '<i>' . wfMsg('mv_label_sitting_type') . "</i>:";
     $html .= '</td><td>';
     $html .= '<select name="sitting_type">';
     $html .= '<option value="Morning" size="30">Morning</option>';
     $html .= '<option value="Afternoon" size="30">Afternoon</option>';
     $html .= '<option value="Emergency" size="30">Emergency</option>';
     $html .= '</select>';
     $html .= '</td>';
     $html .= '</tr>' . "\n";
     $html .= '<tr><td valign="top"><i>' . wfMsg('mv_label_sitting_desc') . '</i>:</td><td>';
     //add an edit token (for the stream description)
     if ($wgUser->isLoggedIn()) {
         $token = htmlspecialchars($wgUser->editToken());
     } else {
         $token = EDIT_TOKEN_SUFFIX;
     }
     $html .= "\n<input type='hidden' value=\"{$token}\"{$docutitle} name=\"wpEditToken\" />\n";
     //output the text area:
     $html .= '<textarea tabindex="1" accesskey="," name="sitting_desc" id="stream_desc" rows=6 cols=5>' . $this->sitting_desc . '</textarea>' . "\n";
     $html .= '<br /><input type="submit" value="' . wfMsg('mv_add_sitting_submit') . "\"/>\n</form>";
     $html .= '</td></tr></table>';
     $html .= '</fieldset>';
     # Output menu items
     # @@todo link with language file
     $wgOut->addHTML($html);
     //output the stream files list (if in edit mode)
     //if($this->mode=='edit')
     //$this->list_streams();
 }
 function execute()
 {
     global $wgRequest, $wgOut, $wgUser, $mvStream_name, $mvgIP;
     #init html output var:
     $html = '';
     # Get request data from, e.g.
     $title_str = $wgRequest->getVal('title');
     //get Mv_Title to normalize the stream name:
     $this->stream_name = $wgRequest->getVal('stream_name') == '' ? '' : MV_Title::normalizeTitle($wgRequest->getVal('stream_name'));
     $this->stream_type = $wgRequest->getVal('stream_type');
     $this->wpEditToken = $wgRequest->getVal('wpEditToken');
     $this->stream_desc = $wgRequest->getVal('stream_desc');
     $this->sitting_id = $wgRequest->getVal('sitting_id');
     $sit = new MV_Sitting(array('id' => $this->sitting_id));
     $sit->db_load_sitting();
     //grab the desc from the wiki page if not in the POST req
     if ($this->stream_desc == '') {
         $desTitle = Title::makeTitle(MV_NS_STREAM, $this->stream_name);
         //grab the article text:
         $curRevision = Revision::newFromTitle($desTitle);
         if ($curRevision) {
             $this->stream_desc = $curRevision->getText();
         }
     }
     if ($this->stream_name == '') {
         //default page request
         $parts = split('/', $title_str);
         if (count($parts) >= 2) {
             //means we can use part 1 as a stream name:
             $this->stream_name = $parts[1];
         }
     } else {
         if ($this->mode == 'add') {
             //output add_ status to html
             //$html.=
             if ($this->add_stream()) {
                 $streamTitle = Title::newFromText($this->stream_name, MV_NS_STREAM);
                 $wgOut->redirect($streamTitle->getLocalURL("action=edit"));
                 return;
             } else {
                 $html = "Error adding stream. Please Nofity Administrator";
                 $wgOut->addHTML($html);
                 return;
             }
         } else {
             //possible edit
         }
     }
     //if edit check for stream name:
     if ($this->mode == 'edit' && $this->stream_name == '') {
         $html .= wfMsg('edit_stream_missing');
         $wgOut->addHTML($html);
         return;
     }
     $this->check_permissions();
     if (count($this->_allowedStreamTypeArray) == 0) {
         //break out user lacks permissions to add anything
         $html .= wfMsg('add_stream_permission');
         $wgOut->addHTML($html);
         return;
     }
     //output the stream form
     //output the add stream form
     $spectitle = Title::makeTitle(NS_SPECIAL, 'Mv_Add_stream');
     $docutitle = Title::newFromText(wfMsg('mv_add_stream'), NS_HELP);
     if ($this->mode == 'edit') {
         $mvStreamTitle = Title::makeTitle(MV_NS_STREAM, $this->stream_name);
         if ($mvStreamTitle->exists()) {
             $sk = $wgUser->getSkin();
             $streamLink = $sk->makeLinkObj($mvStreamTitle, $this->stream_name);
             $html .= wfMsg('mv_edit_strea_docu', $streamLink);
         }
     } else {
         //$html.= wfMsg('mv_add_stream_docu', $docutitle->getFullURL()) ."\n";
         $title2 = Title::makeTitle(MV_NS_SITTING, $sit->name);
         $skin2 = new Linker();
         $sittingLink = $skin2->makeKnownLinkObj($title2, $sit->name);
         $html .= 'Add a stream to Sitting ' . $sittingLink;
     }
     $html .= '<form name="add_stream" action="' . $spectitle->escapeLocalURL() . '" method="post" enctype="multipart/form-data">';
     $html .= '<fieldset><legend>' . wfMsg('mv_add_stream') . '</legend>' . "\n" . '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '"/>' . '<input type="hidden" name="sitting_id" value="' . $wgRequest->getVal('sitting_id') . '"/>';
     $html .= '<table width="600" border="0">';
     $html .= '<tr><td width="140">Sitting Id</td><td>' . $wgRequest->getVal('sitting_id') . '</tr><tr>';
     $html .= '<td>';
     //output the stream type pulldown
     $html .= '<i>' . wfMsg('mv_label_stream_name') . "</i>:";
     $html .= '</td><td>';
     $html .= '<input type="text" name="stream_name" value="' . htmlspecialchars(MV_Title::getStreamNameText($this->stream_name)) . '" size="30" maxlength="1024"><br />' . "\n";
     $html .= '</td>';
     $html .= '<td><tr><td><i>' . wfMsg('mv_label_stream_type') . '</i></td><td>';
     $html .= '<select name="stream_type">' . '<option value="">Select Stream Type</option>' . "\n";
     foreach ($this->_allowedStreamTypeArray as $type => $na) {
         $sel = $type == $this->stream_type ? 'selected' : '';
         $html .= '<option value="' . $type . '" ' . $sel . '>' . wfMsg('mv_' . $type) . '</option>' . "\n";
     }
     $html .= '</select></tr>' . "\n";
     $html .= '<tr><td valign="top"><i>' . wfMsg('mv_label_stream_desc') . '</i>:</td><td>';
     //add an edit token (for the stream description)
     if ($wgUser->isLoggedIn()) {
         $token = htmlspecialchars($wgUser->editToken());
     } else {
         $token = EDIT_TOKEN_SUFFIX;
     }
     $html .= "\n<input type='hidden' value=\"{$token}\"{$docutitle} name=\"wpEditToken\" />\n";
     //output the text area:
     $html .= '<textarea tabindex="1" accesskey="," name="stream_desc" id="stream_desc" rows=6 cols=5>' . $this->stream_desc . '</textarea>' . "\n";
     $html .= '<br /><input type="submit" value="' . wfMsg('mv_add_stream_submit') . "\"/>\n</form>";
     $html .= '</td></tr></table>';
     $html .= '</fieldset>';
     # Output menu items
     # @@todo link with language file
     $wgOut->addHTML($html);
     //output the stream files list (if in edit mode)
     if ($this->mode == 'edit') {
         $this->list_stream_files();
     }
 }
 function formatResult($skin, $result)
 {
     global $wgUser, $wgLang, $mvImageArchive;
     $sit = new MV_Sitting(array('id' => $this->sitting_id));
     $sit->db_load_sitting();
     #make sure the first letter is upper case (makeTitle() should do that)
     $result->title = strtoupper($result->title[0]) . substr($result->title, 1);
     $img_url = $mvImageArchive . $result->title . '?size=icon&time=0:00:00';
     $img_url = MV_StreamImage::getStreamImageURL($result->stream_id, '0:00:00', 'icon', true);
     $img_html = '<img src="' . $img_url . '" width="80" height="60">';
     $title = Title::makeTitle(MV_NS_STREAM, $result->title);
     $rlink = $skin->makeLinkObj($title, $img_html . ' ' . $title->getText());
     //if admin expose an edit link
     if ($this->existing == 'false') {
         $rlink .= ' ' . $skin->makeKnownLinkObj(Title::makeTitle(MV_NS_STREAM, $title->getText()), 'edit', 'action=edit');
     } else {
         $rlink .= ' ' . $skin->makeKnownLinkObj(Title::makeTitle(MV_NS_SITTING, $sit->name), 'add', 'action=edit&mv_action=add&stream_id=' . $result->stream_id);
     }
     return $rlink;
 }
function mvDoMetavidSittingpage($title, $article)
{
	global $wgRequest;
	$name = $title->getDBKey();
	$sit = new MV_Sitting(array('name'=>$name));
	$sit->db_load_sitting();
	if ($wgRequest->getVal('action') != 'edit')
	{
		list( $limit, $offset ) = wfCheckLimits();
		$spec = new MV_SpecialListStreams($sit->id,'false');
		$spec->doQuery( $offset, $limit );
		return true;
	}
}
function mv_save_staff()
{
    $MV_Sitting = new MV_Sitting();
    return $MV_Sitting->save_staff($_REQUEST['xmldata'], $_REQUEST['sitting_id']);
}