示例#1
0
 function process()
 {
     if ($this->validate()) {
         $this->election_details->name = trim($this->data['txtName']);
         $this->election_details->vote_date = DB_DataObject_Cast::date($this->data['txtDate']);
         if ($this->data['chkEnabled']) {
             $this->election_details->enabled = 1;
         } else {
             $this->election_details->enabled = 0;
         }
         $this->process_removed_categories();
         $this->process_selected_categories();
         $this->process_removed_parties();
         $this->process_selected_parties();
         if ($this->election_details->update() !== false) {
             $this->load();
             // Reload so we get the date back as a string
             $this->bind();
             $this->render();
         } else {
             trigger_error("Unable to save election");
         }
     } else {
         $this->bind();
         $this->render();
     }
 }
示例#2
0
 function process()
 {
     if ($this->validate()) {
         $election = factory::create('election');
         $election->name = trim($this->data['txtName']);
         $election->vote_date = DB_DataObject_Cast::date($this->data['txtDate']);
         if ($election->insert()) {
             $this->bind();
             $this->render();
         } else {
             trigger_error("Unable to save election");
         }
     } else {
         $this->bind();
         $this->render();
     }
 }
示例#3
0
 /**
  * DateTime Constructor
  *
  * create a Cast object from a Date/Time
  * Maybe should accept a Date object.!
  * NO VALIDATION DONE, although some crappy re-calcing done!
  * 
  * @param   vargs... accepts
  *              noargs (now)
  *              yyyy-mm-dd HH:MM:SS (Iso)
  *              array(yyyy,mm,dd,HH,MM,SS) 
  *
  *
  * @return   object DB_DataObject_Cast
  * @access   public 
  * @author   therion 5 at hotmail
  */
 function dateTime()
 {
     $args = func_get_args();
     switch (count($args)) {
         case 0:
             // no args = now!
             $datetime = date('Y-m-d G:i:s', mktime());
         case 1:
             // continue on from 0 args.
             if (!isset($datetime)) {
                 $datetime = $args[0];
             }
             $parts = explode(' ', $datetime);
             $bits = explode('-', $parts[0]);
             $bits = array_merge($bits, explode(':', $parts[1]));
             break;
         default:
             // 2 or more..
             $bits = $args;
     }
     if (count($bits) != 6) {
         // PEAR ERROR?
         return false;
     }
     $r = DB_DataObject_Cast::date($bits[0], $bits[1], $bits[2]);
     if (!$r) {
         return $r;
         // pass thru error (False) - doesnt happen at present!
     }
     // change the type!
     $r->type = 'datetime';
     // should we mathematically sort this out..
     // (or just assume that no-one's dumb enough to enter 26:90:90 as a time!
     $r->hour = $bits[3];
     $r->minute = $bits[4];
     $r->second = $bits[5];
     return $r;
 }
 static function updateCount($d, $n)
 {
     $suc = Sitemap_user_count::getKV('registration_date', DB_DataObject_Cast::date($d));
     if (empty($suc)) {
         // TRANS: Exception thrown when a registration date cannot be found.
         throw new Exception(_m("No such registration date: {$d}."));
     }
     $orig = clone $suc;
     $suc->registration_date = DB_DataObject_Cast::date($d);
     $suc->user_count = $n;
     $suc->created = common_sql_now();
     $suc->modified = $suc->created;
     if (!$suc->update($orig)) {
         common_log(LOG_WARNING, "Could not save user counts for '{$d}'");
     }
 }
    function renderDayView($y, $m, $d, &$used_hours_arr)
    {
        global $TemplateDir, $template, $WebUploadDir, $WebTemplateDir, $WebBaseDir, $ClassDir, $i18n, $ActiveOption, $userid;
        include_once $ClassDir . "URLHelper.class.php";
        // Create a day to view the hours for
        $Day =& new Calendar_Day($y, $m, $d);
        $selection = array();
        // search specify day webcasts
        $apf_schedule = DB_DataObject::factory('ApfSchedule');
        $apf_schedule->setPublishDate(DB_DataObject_Cast::date($y, $m, $d));
        //		$apf_schedule->debugLevel(4);
        $apf_schedule->setUserid($userid);
        $apf_schedule->find();
        $result = array();
        $SHOW_CONFIRM_BUTTON = true;
        $selected_hours = 0;
        while ($apf_schedule->fetch()) {
            $row = $apf_schedule->toArray();
            //		    Var_Dump::display($row);
            $start_hour = $this->getHourByTime($apf_schedule->getPublishStarttime());
            $end_hour = $this->getHourByTime($apf_schedule->getPublishEndtime());
            if ($row['webcast_status'] != 'file' && !$row['webcast_file']) {
                $SHOW_CONFIRM_BUTTON = false;
            }
            for ($index = $start_hour; $index <= $end_hour; $index++) {
                $used_hours_arr["{$index}:00:00"] = "{$index}:00";
            }
            $selected_hours += $end_hour - $start_hour + 1;
            $Hour = new Calendar_Hour(2000, 1, 1, 1);
            // Create Hour with dummy values
            $Hour->setTimeStamp(mktime($start_hour, 0, 0, $m, $d, $y));
            // Set the real time with setTimeStamp
            // Create the decorator, passing it the Hour
            $DiaryEvent = new DiaryEvent($Hour);
            // Attach the payload
            $DiaryEvent->setEndHour($end_hour);
            $DiaryEvent->setID($row['id']);
            $DiaryEvent->setStatu($row['active']);
            $DiaryEvent->setImages($row['image'] ? popFile($WebUploadDir . $row['image']) : "");
            $DiaryEvent->setEntry("<a href=\"{$WebBaseDir}/schedule/apf_schedule/list/" . $row['id'] . "?y={$y}&m={$m}&d={$d}\">" . $apf_schedule->getTitle() . "</a>");
            // Add the decorator to the selection
            $selection[] = $DiaryEvent;
        }
        if ($selected_hours < 24) {
            $SHOW_CONFIRM_BUTTON = false;
        }
        if ($SHOW_CONFIRM_BUTTON) {
            $template->setVar(array("CONFIRM_LINK" => '<li><input type="submit" name="save" value="Status To Confirm" class="admin_action_cancel" onclick="if (confirm(\'Are you sure?\')) { document.admin_list_form.todo.value=\'confirm\';document.admin_list_form.submit(); };return false;" /></li>'));
        }
        $Day->build($selection);
        $Day_String = "";
        $DayViewTitle = date('D d F Y', $Day->thisDay(TRUE));
        $temp_end_hour = "";
        while ($Hour =& $Day->fetch()) {
            $hour = $Hour->thisHour();
            $minute = $Hour->thisMinute();
            // Office hours only...
            if ($hour >= 0 && $hour <= 24) {
                $Day_String .= "<tr class=\"calnone\">\n";
                $Day_String .= "<td>{$hour}:{$minute}</td>\n";
                // If the hour is selected, call the decorator method...
                if ($Hour->isSelected()) {
                    $temp_end_hour = $Hour->getEndHour();
                    $merge_hour = $temp_end_hour - $hour + 1;
                    $css_class_name = "calentryfilled_" . $Hour->getStatu();
                    $Day_String .= "<td rowspan=\"{$merge_hour}\" class=\"{$css_class_name}\"><INPUT TYPE=\"checkbox\" NAME=\"SelectID[]\" value=\"" . $Hour->getID() . "\"></td><td class=\"{$css_class_name}\" rowspan=\"{$merge_hour}\">" . $Hour->getEntry() . "</td><td rowspan=\"{$merge_hour}\">&nbsp;" . $Hour->getImages() . "</td><td rowspan=\"{$merge_hour}\">&nbsp;" . $ActiveOption[$Hour->getStatu()] . "</td><td rowspan=\"{$merge_hour}\"><ul class=\"admin_td_actions\">\n  <li><a onclick=\"if (confirm('Are you sure?')) { f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;\" href=\"{$WebBaseDir}/schedule/apf_schedule/del/" . $Hour->getID() . "?y={$y}&m={$m}&d={$d}\"><img alt=\"delete\" title=\"delete\" src=\"" . URLHelper::getWebBaseURL() . $WebTemplateDir . "/images/delete_icon.png\" /></a></li>\n</ul></td>\n";
                } else {
                    if ($temp_end_hour && $hour <= $temp_end_hour) {
                        $Day_String .= "";
                    } else {
                        $Day_String .= "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>\n";
                    }
                }
                $Day_String .= "</tr>\n";
            }
        }
        $header_time = $i18n->_("Time");
        $header_entry = $i18n->_("Entry");
        $header_image = $i18n->_("Image");
        $header_status = $i18n->_("Status");
        $header_action = $i18n->_("Action");
        $header_schedule_for = $i18n->_("YourScheduleFor");
        $calendar_str = <<<EOD
<table>
<caption><b>{$header_schedule_for}{$DayViewTitle} </b></caption>
<tr class="calentryhead">
<th width="8%">{$header_time}</th>
<th width="1%">&nbsp;<input type="checkbox" onClick="selectAll(this.checked,'SelectID[]')"/></th>
<th>{$header_entry}</th>
<th width="10%">{$header_image}</th>
<th width="10%">{$header_status}</th>
<th width="10%">{$header_action}</th>
</tr>
{$Day_String}
</table>
EOD;
        return $calendar_str;
    }
 static function updateCount($d, $n)
 {
     $snc = Sitemap_notice_count::staticGet('notice_date', DB_DataObject_Cast::date($d));
     if (empty($snc)) {
         // TRANS: Exception
         throw new Exception(_m("No such registration date: {$d}."));
     }
     $orig = clone $snc;
     $snc->notice_date = DB_DataObject_Cast::date($d);
     $snc->notice_count = $n;
     $snc->created = common_sql_now();
     $snc->modified = $snc->created;
     if (!$snc->update($orig)) {
         common_log(LOG_WARNING, "Could not save user counts for '{$d}'");
     }
 }