/** * This is a temp solution, we need something better depending * on authority to update activity stored. * **/ public function saveActivity($activity_id, $activity_def) { $exists = \Activity::find($activity_id); //if the object activity exists, remove and update with recent if ($exists) { \Activity::where('_id', $activity_id)->delete(); } //save record \Activity::insert(array('_id' => $activity_id, 'definition' => $activity_def)); }
public function commit() { if ($this->valid_origin) { $av = new ActivityValidate(array('writer' => $this->writer, 'target' => $this->target, 'title' => $this->title, 'description' => $this->description, 'begin' => $this->begin, 'end' => $this->end, 'origin' => $this->origin)); $v = new Validate(array('writer' => $this->writer, 'group' => $this->target->group(), 'item' => $av, 'type' => 'activity')); $v->insert(); } else { $a = new Activity(array('target' => $this->target, 'origin' => $this->origin, 'title' => $this->title, 'description' => $this->description, 'days' => '')); $a->insert(); $ai = new ActivityInstance(array('activity' => $a, 'writer' => $this->writer, 'comment' => '', 'begin' => $this->begin, 'end' => $this->end)); $ai->insert(); } return true; }
/** * * * @access public */ function add_save() { $title = get_post_value('title'); $language = get_post_value('language'); $start_time = get_post_value('start_time'); $end_time = get_post_value('end_time'); $filename = get_post_value('filename'); $num = count($filename); //print_r($filename); $m = new Activity(); if ($filename != '' && count($filename) > 0) { $order = 0; for ($i = 0; $i < $num; $i++) { $field = array('title' => trim($title), 'language' => $language, 'start_time' => $start_time, 'end_time' => $end_time, 'created_name' => '', 'status' => '10000', 'img_path' => '/Upload/' . $filename[$i], 'orders' => $order, 'created' => date('Y-m-d H:i:s', time())); $m->clear(); $m->setTable('vcb_index_activity'); $m->setField($field); $product_id = $m->insert(); $order++; } } if (!$product_id) { echo '<br>保存失败<br>'; } else { echo '<br>保存成功,<a href="add">继续添加</a>,<a href="activity">返回</a><br>'; } }
function handler_new_regular($page) { $title = Env::t('title', ''); $description = Env::t('activity_description', ''); $default_begin = Env::t('begin', '00:00'); $default_end = Env::t('end', '00:00'); $days = Env::v('days'); $target = Env::i('target_group_activity', ''); $caste = Env::has('target_everybody_activity') ? 'everybody' : 'restricted'; if (Env::has('send')) { S::assert_xsrf_token(); if ($title == '' || is_null($days) || $default_begin == '00:00' || $default_end == '00:00' || $target == '' || !(preg_match('`^\\d{2}:\\d{2}$`', $default_begin) && strtotime($default_begin) !== false && preg_match('`^\\d{2}:\\d{2}$`', $default_end) && strtotime($default_end) !== false)) { $page->assign('msg', 'Il manque des informations pour créer l\'activité. Attention les heures ne peuvent pas rester de la forme 00:00.'); } else { $days = implode(',', $days); $target = new Group($target); $target->select(GroupSelect::validate()); if (!S::user()->hasRights($target, Rights::admin())) { throw new Exception("Invalid credentials"); } if ($target->ns() == Group::NS_USER) { $caste = 'restricted'; } $a = new Activity(array('target' => $target->caste(new Rights($caste)), 'origin' => $target, 'title' => $title, 'description' => $description, 'days' => $days, 'default_begin' => $default_begin, 'default_end' => $default_end)); $a->insert(); $page->assign('envoye', true); } } $page->assign('title_activity', $title); $page->assign('description', $description); $page->assign('begin', $default_begin); $page->assign('end', $default_end); $page->assign('title', 'Créer une activité régulière'); $page->changeTpl('activity/create_regular_activity.tpl'); }
public function createActivity($args) { // First add geo location to geonames_cache if it doesn't exist yet $locationId = $args->post['activity-location-id']; if ($locationId != 0) { $geomodel = new GeoModel(); $geomodel->addGeonameId($locationId, 'member_primary'); } else { $locationId = $this->getLoggedInMember()->IdCity; } $activity = new Activity(); $activity->creator = $this->getLoggedInMember()->id; $activity->title = $args->post['activity-title']; $activity->address = $args->post['activity-address']; $activity->locationId = $locationId; $startdate = strtotime($args->post['activity-start-date']); $activity->dateTimeStart = date('Y-m-d H:i:s', $startdate); $enddate = strtotime($args->post['activity-end-date']); $activity->dateTimeEnd = date('Y-m-d H:i:s', $enddate); $activity->description = $args->post['activity-description']; $activity->public = isset($args->post['activity-public']); $organizer = array(); $organizer[$activity->creator] = array("attendeeId" => $activity->creator, "organizer" => "1", "status" => "1"); $activity->organizers = $organizer; $activity->insert(); return $activity; }