/** * Instance an activity object and updated the time stamp or * if the flag="new" insert a new entry (only for new record) */ function setActivity($flag = "") { if (!empty($this->idcontact)) { $do_activity = new Activity(); $do_activity->idcontact = $this->idcontact; if ($flag == "new") { $do_activity->add(); } else { $do_activity->update(); } $q = new sqlQuery($GLOBALS['conx']); $q->query("UPDATE " . $this->getSqlViewName() . " SET last_activity=now() WHERE idcontact=" . $this->idcontact); $q->free(); } }
/** * While adding a tag association just check if it is * already there. IF not then add that. */ function addTagAssociation($idreference, $tag_name = "", $reference_type = "", $iduser = 0) { if (empty($iduser)) { $iduser = $_SESSION['do_User']->iduser; } if (empty($reference_type)) { $reference_type = $this->default_reference; } $tag_name = trim($tag_name); if (!empty($tag_name)) { if (!$this->isTagAssociationExists($tag_name, $idreference, $reference_type, $iduser)) { if ($reference_type == "contact") { $activity = new Activity(); $activity->idcontact = $idreference; $activity->update(); } $this->addNew(); $this->iduser = $iduser; $this->tag_name = $tag_name; $this->reference_type = $reference_type; $this->idreference = $idreference; $this->date_added = date("Y-m-d"); $this->add(); $this->calculateTagSize(); } } }
/** * * @access public */ function delete() { if ($this->verify()) { echo '<br>数据不可修改.<a href="activity">返回</a><br>'; return; } $id = get_post_value('id'); $field = array('status' => '60000'); $m = new Activity(); $m->clear(); $m->setField($field); ///设置更新字段及值,(键值数组) $m->setTable('vcb_index_activity'); //设置表名 $m->setWhere('activity_id', '=', $id); //设置Where条件 $m->update(); //返回 echo '<br>操作成功,<a href="activity" >返回</a><br>'; }
function testUpdate() { //Arrange $activity_name = "Activity One"; $activity_date = '2016-01-01'; $activity_location = "Location"; $activity_description = "Description of Activity One"; $activity_price = "Price of Activity One"; $activity_quantity = 10; $business_id = 1; $activity_category_id = 2; $id = 1; $test_activity = new Activity($activity_name, $activity_date, $activity_location, $activity_description, $activity_price, $activity_quantity, $business_id, $activity_category_id, $id); $test_activity->save(); $new_activity_name = "Activity Two"; //Act $test_activity->update($new_activity_name); //Assert $this->assertEquals("Activity Two", $test_activity->getActivityName()); }
public function updateActivity($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($args->post['activity-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']); $activity->update(); return $activity; }