/**
  * Updates a license
  *
  * @param int $lid ["path","0"]
  *  The id of the license to update
  * @param object $license ["data"]
  *  The license object
  * @return object
  *
  * @Access(callback='user_access', args={'update content licenses'}, appendArgs=false)
  */
 public static function update($lid, $license)
 {
     $res = array();
     $event['lid'] = $lid;
     $res['lid'] = ContentLicense::write($license);
     $res['uri'] = services_resource_uri(array('content_license', $res['lid']));
     return (object) $res;
 }
 /**
  * Retrieves a listing of texts
  *
  * @param int $page ["param","page"]
  * @param string $fields ["param","fields"]
  * @param array $parameters ["param"]
  * @return array
  *
  * @Access(callback='user_access', args={'access content'}, appendArgs=false)
  */
 public static function index($page = 0, $fields = array(), $parameters = array())
 {
     $builder = new QueryBuilder();
     if ($params['__action'] == 'describe') {
         return $builder->describe();
     }
     if (is_string($fields)) {
         $fields = preg_split('/,\\s?/', $fields);
     }
     $parameters['status'] = 1;
     $parameters['type'] = 'docuwalk_text';
     list($sql, $params) = $builder->query($fields, $parameters);
     $res = db_query_range($sql, $params, $page * 20, 20);
     $nodes = array();
     while ($node = db_fetch_object($res)) {
         $node->uri = services_resource_uri(array('docuwalk-text', $node->nid));
         $nodes[] = $node;
     }
     return $nodes;
 }
 /**
  * Helper function that maps incoming data to the proper node attributes
  *
  * @param object $node
  * @param object $data
  * @return object
  */
 private static function nodeWrite($node, $data)
 {
     $oauth_consumer = services_get_server_info('oauth_consumer');
     $source = conglomerate_source_from_consumer($oauth_consumer);
     $attr = array('title' => array('required' => TRUE), 'text' => array('to' => 'body', 'required' => TRUE), 'position' => array('to' => 'simple_geo_position', 'required' => TRUE), 'tags' => array('required' => FALSE, 'adapt' => 'adaptTags'), 'metadata' => array('required' => FALSE, 'to' => 'conglomerate_metadata'), 'picture' => array('required' => FALSE, 'adapt' => 'adaptPicture'), 'large_picture' => array('required' => FALSE, 'adapt' => 'adaptLargePicture'), 'url' => array('required' => TRUE, 'adapt' => 'adaptUrl'), 'fulltext' => array('required' => FALSE, 'adapt' => 'adaptFulltext'), 'type' => array('required' => TRUE), 'language' => array('required' => TRUE), 'comments' => array('required' => FALSE));
     switch ($data->type) {
         case 'event':
             $attr['starts'] = array('adapt' => 'adaptStartTime', 'required' => TRUE);
             break;
         case 'subpage':
             $attr['searchable'] = array('adapt' => 'adaptSearchable', 'required' => TRUE);
             break;
     }
     drupal_alter('conglomerate_node_write_attributes', $attr, $data, $source);
     // Transfer attributes from data
     foreach ($attr as $name => $info) {
         if (isset($data->{$name})) {
             $to = $name;
             if (!empty($info['to'])) {
                 $to = $info['to'];
             }
             $node->{$to} = $data->{$name};
             if (isset($info['adapt'])) {
                 call_user_func('ConglomerateContentResource::' . $info['adapt'], $node);
             }
         } else {
             if ($info['required']) {
                 return services_error("Missing attribute {$name}", 406);
             }
         }
     }
     // Add information about the conglomerate source
     $node->conglomerate_source = $source->sid;
     $the_language = $node->language;
     node_save($node);
     // Workaround to preserve language. TODO: Must find out what is happening to the language.
     if (!$node->language) {
         db_query("UPDATE {node} SET language='%s' WHERE nid = %d", array(':language' => $the_language, ':nid' => $node->nid));
     }
     return (object) array('nid' => $node->nid, 'uri' => services_resource_uri(array('conglomerate-content', $node->nid)), 'url' => url('node/' . $node->nid, array('absolute' => TRUE)));
 }