/** * Test if the calendar date property is correctly added to the post data. */ public function testCalendarDateToPostData() { $activity = new CultureFeed_Activity(); $result = $activity->toPostData(); $this->assertFALSE(array_key_exists('calendarDate', $result)); $activity->calendarDate = '2011-07-25T22:03Z'; $result = $activity->toPostData(); $this->assertTRUE(array_key_exists('calendarDate', $result)); }
/** * Load the activity counts for drupal nodes. */ public function loadActivityCounts() { try { // Add the different activity counts. $query = new CultureFeed_SearchActivitiesQuery(); $query->contentType = CultureFeed_Activity::CONTENT_TYPE_NODE; $query->type = array(CultureFeed_Activity::TYPE_RECOMMEND); $query->nodeId = url('node/' . $this->getEntity()->nid, array('absolute' => TRUE)); $query->private = FALSE; $activitiesResult = DrupalCultureFeed::searchActivities($query); $stringType = CultureFeed_Activity::getNameById(CultureFeed_Activity::TYPE_RECOMMEND); $this->activityCounts[$stringType] = $activitiesResult->total; $query->type = array(CultureFeed_Activity::TYPE_COMMENT); $activitiesResult = DrupalCultureFeed::searchActivities($query); $stringType = CultureFeed_Activity::getNameById(CultureFeed_Activity::TYPE_COMMENT); $this->activityCounts[$stringType] = $activitiesResult->total; } catch (Exception $e) { watchdog_exception('culturefeed', $e); } }
/** * Create a new activity. * * The object should be initialized with the consumer token and user access token of the user who is acted upon. * * @param CultureFeed_Activity $activity * The activity to create. * * @return CultureFeed_Activity * * @throws CultureFeed_ParseException * If the result could not be parsed. */ public function createActivity(CultureFeed_Activity $activity) { $data = $activity->toPostData(); $result = $this->oauth_client->authenticatedPostAsXml('activity', $data); try { $xml = new CultureFeed_SimpleXMLElement($result); } catch (Exception $e) { throw new CultureFeed_ParseException($result); } $id = $xml->xpath_str('/response/activityId'); if (!empty($id)) { $activity->id = $id; $activityPoints = $xml->xpath('/response/activityPointsList/activityPoints'); if (!empty($activityPoints)) { $activity->newTotalPoints = $activityPoints[0]->xpath_float('newTotalPoints'); $activity->points = $activityPoints[0]->xpath_float('savedPoints'); $activity->userpointsUserId = $activityPoints[0]->xpath_str('uitIdUser/rdf:id'); } return $activity; } throw new CultureFeed_ParseException($result); }