当前位置: 首页>>代码示例>>PHP>>正文


PHP Dal::commit方法代码示例

本文整理汇总了PHP中Dal::commit方法的典型用法代码示例。如果您正苦于以下问题:PHP Dal::commit方法的具体用法?PHP Dal::commit怎么用?PHP Dal::commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dal的用法示例。


在下文中一共展示了Dal::commit方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_relation

 /**
  * Add the friend in the database by giving their user_id as relations_id.
  * @param int $relation_id This is user id of the user to whom user is adding as a friend
  * if this relation_id is given as -1, it is a external relation (flickr friend etc)
  * in that case the extra parameters MUST be supplied
  * in_family parameter added  by gurpreet to mark whether the person added is in family.
  */
 public static function add_relation($user_id, $relation_id, $relation_type_id = 2, $network = NULL, $network_uid = NULL, $display_name = NULL, $thumbnail_url = NULL, $profile_url = NULL, $in_family = null, $status = APPROVED)
 {
     // status added 04/01/2007
     Logger::log("Enter: function Relation::add_relation\n");
     if (!$relation_id) {
         throw new PAException(REQUIRED_PARAMETERS_MISSING, "Required variable relation id is not specified");
     }
     if ($relation_id < 0 && !$network_uid) {
         throw new PAException(REQUIRED_PARAMETERS_MISSING, "Required variable network_uid is not specified");
     }
     if ($relation_id == $user_id) {
         throw new PAException(USER_INVALID, "User is invalid to be added as friend. User can not add himself as a friend");
     }
     // make sure that the user to be added is active
     // but only if it is an internal user
     // relations from external networs have a
     // $relation_id of -1
     if ((int) $relation_id > 0) {
         $user_exist = User::user_exist((int) $relation_id);
         if ($user_exist == FALSE) {
             Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
             throw new PAException(USER_NOT_FOUND, 'User does not exist.');
         }
     }
     try {
         // Delete an existing relation
         if (is_null($network_uid)) {
             $sql = 'DELETE FROM {relations} WHERE user_id = ? AND relation_id = ? AND network_uid IS ?';
         } else {
             $sql = 'DELETE FROM {relations} WHERE user_id = ? AND relation_id = ? AND network_uid = ?';
         }
         $data = array($user_id, $relation_id, $network_uid);
         Dal::query($sql, $data);
         // Insert relation_id for corresponding user_id
         $sql = 'INSERT into {relations} 
     (user_id, relation_id, relationship_type,
     network, network_uid, display_name,
     thumbnail_url, profile_url, in_family, status) 
     values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
         $data = array($user_id, $relation_id, $relation_type_id, $network, $network_uid, $display_name, $thumbnail_url, $profile_url, $in_family, $status);
         Dal::query($sql, $data);
         // Finally - commit our changes to the DB
         Dal::commit();
     } catch (PAException $e) {
         // roll back database operations and re-throw the exception
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: function Relation::add_relation");
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:57,代码来源:Relation.php

示例2: save

 public function save()
 {
     Logger::log("Enter: EventAssociation::save");
     // check for complete info
     if (empty($this->event_id)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: event_id is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'event_id is missing.');
     }
     if (empty($this->assoc_target_type)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: assoc_target_type is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'assoc_target_type is missing.');
     }
     if (empty($this->assoc_target_id)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: assoc_target_id is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'assoc_target_id is missing.');
     }
     if (empty($this->assoc_target_name)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: assoc_target_name is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'assoc_target_name is missing.');
     }
     // depending on assoc_target_type check if network|group|user exists
     switch ($this->assoc_target_type) {
         case "network":
             // network of assoc_target_id exists?
             // this check should maybe be part of the Network class?
             $res = Dal::query("SELECT COUNT(*) FROM {networks} \n          WHERE network_id=? AND is_active=1", array($this->assoc_target_id));
             if (!$res->numRows()) {
                 Logger::log(" Throwing exception NETWORK_NOT_FOUND | Message: Network does not exist", LOGGER_ERROR);
                 throw new PAException(NETWORK_NOT_FOUND, 'Network does not exist.');
             }
             break;
         case "group":
             // group of assoc_target_id exists?
             $res = Dal::query("SELECT COUNT(*) FROM {groups} \n          WHERE group_id=?", array($this->assoc_target_id));
             if (!$res->numRows()) {
                 Logger::log(" Throwing exception GROUP_NAME_NOT_EXIST | Message: Group does not exist", LOGGER_ERROR);
                 throw new PAException(GROUP_NAME_NOT_EXIST, 'Group does not exist.');
             }
             break;
         case "user":
             // user of assoc_target_id exists?
             if (!User::user_exist($this->assoc_target_id)) {
                 Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
                 throw new PAException(USER_NOT_FOUND, 'User does not exist.');
             }
             break;
         default:
             // oh-oh, not a valid assoc_target_type!!
             Logger::log(" Throwing exception BAD_PARAMETER | Message: " . $this->assoc_target_type . " is not a valid assoc_target_type", LOGGER_ERROR);
             throw new PAException(BAD_PARAMETER, $this->assoc_target_type . " is not a valid assoc_target_type");
             break;
     }
     // check to prevent duplicate associations
     if (EventAssociation::assoc_exists($this->assoc_target_type, $this->assoc_target_id, $this->event_id)) {
         Logger::log(" Throwing exception BAD_PARAMETER | Message: " . "There already is an EventAsssociation for this network, group or user.", LOGGER_ERROR);
         throw new PAException(BAD_PARAMETER, "The Event is already associated to this " . $this->assoc_target_type . ".");
     }
     if (!Event::exists($this->event_id)) {
         Logger::log(" Throwing exception EVENT_NOT_EXIST | Message: Event does not exist", LOGGER_ERROR);
         throw new PAException(EVENT_NOT_EXIST, 'Event does not exist.');
     }
     // load the Event if not already loaded
     if (!$this->event) {
         $this->load_event($this->event_id);
     }
     // serialize assoc_data for storage
     $assoc_data = "";
     if (!empty($this->assoc_data)) {
         $assoc_data = serialize($this->assoc_data);
     }
     // are we creating a new one?
     if (!$this->assoc_id) {
         // do we have a real User set as owner?
         if (!User::user_exist($this->user_id)) {
             Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
             throw new PAException(USER_NOT_FOUND, 'User does not exist.');
         }
         // do we have an Event?
         if (!Event::exists($this->event->event_id)) {
             Logger::log(" Throwing exception EVENT_NOT_EXIST | Message: Event does not exist", LOGGER_ERROR);
             throw new PAException(EVENT_NOT_EXIST, 'Event does not exist.');
         }
         $sql = "INSERT INTO events_associations \n      (event_id, user_id, assoc_target_type, assoc_target_id, assoc_target_name, event_title, start_time, end_time, assoc_data) \n      VALUES (?,?,?,?,?,?,?,?,?)";
         $data = array($this->event->event_id, $this->user_id, $this->assoc_target_type, $this->assoc_target_id, $this->assoc_target_name, $this->event->event_title, $this->event->start_time, $this->event->end_time, $assoc_data);
     } else {
         $sql = "UPDATE {events_associations} SET " . "event_id = ?, user_id = ?, assoc_target_type = ?, assoc_target_id = ?,\n           assoc_target_name = ?, event_title = ?, start_time = ?, end_time = ?,\n           assoc_data = ?" . "WHERE assoc_id = ?";
         $data = array($this->event->event_id, $this->user_id, $this->assoc_target_type, $this->assoc_target_id, $this->assoc_target_name, $this->event->event_title, $this->event->start_time, $this->event->end_time, $assoc_data, $this->assoc_id);
     }
     // write to DB
     try {
         Dal::query($sql, $data);
         if (!$this->assoc_id) {
             $this->assoc_id = Dal::insert_id();
         }
         // Finally - commit our changes to the DB
         Dal::commit();
     } catch (PAException $e) {
         // roll back database operations and re-throw the exception
         Dal::rollback();
         throw $e;
//.........这里部分代码省略.........
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:101,代码来源:EventAssociation.php

示例3: save

 /**
  * Save the persona data to the database.
  *
  * When creating a new persona, set all the attributes for the persona 
  * (except persona_id) and call save. Save will set the persona_id for 
  * the persona.
  *
  */
 public function save()
 {
     Logger::log("Enter: function Persona::save");
     // If we have decoded the JSON coniguration string into the structured
     // configuration data, it will be non-null, so encode it back as a JSON
     // string into configuration, to save it.
     if ($this->configuration_data != null) {
         $this->encode_configuration();
     }
     try {
         if (!$this->user_id || !$this->persona_service_id) {
             Logger::log("Throwing exception REQUIRED_PARAMETERS_MISSING | Message: Required parameters missing", LOGGER_ERROR);
             throw new PAException(REQUIRED_PARAMETERS_MISSING, "Required parameters missing");
         }
         if ($this->is_new) {
             $this->is_new = false;
             $sql = 'INSERT INTO {personas} (user_id, persona_service_id, sequence, name, configuration) values (?, ?, ?, ?, ?)';
             $data = array($this->user_id, $this->persona_service_id, $this->sequence, $this->name, $this->configuration);
             Dal::query($sql, $data);
             $this->persona_id = Dal::insert_id();
         } else {
             $sql = 'UPDATE {personas} SET user_id = ?, persona_service_id = ?, sequence = ?, name = ?, configuration = ? WHERE persona_id = ?';
             $data = array($this->user_id, $this->persona_service_id, $this->sequence, $this->name, $this->configuration, $this->persona_id);
             Dal::query($sql, $data);
         }
         // All done - commit to database.
         Dal::commit();
     } catch (PAException $e) {
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: function Persona::save");
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:41,代码来源:Persona.php

示例4: save

 /**
  * Saves Group data to database
  * @access public
  * @param int $user_id ID of the user trying to save
  */
 public function save($user_id)
 {
     Logger::log("Enter: Group::save() | Args: \$user_id = {$user_id}");
     //print_r($this);
     if (!$this->title) {
         Logger::log(GROUP_NAME_NOT_EXIST, "No name found with collection_id = {$this->content_id}");
         throw new PAException(GROUP_NAME_NOT_EXIST, "The name of group does not exist.It is a required field.");
     }
     if (!isset($this->access_type)) {
         Logger::log(GROUP_ACCESS_TYPE_NOT_EXIST, "No access type set with collection_id = {$this->content_id}");
         throw new PAException(GROUP_ACCESS_TYPE_NOT_EXIST, "The access type of group does not exist.It is a required field.");
     }
     if (!isset($this->reg_type)) {
         Logger::log(GROUP_REGISTRATION_TYPE_NOT_EXIST, "No registration type set with collection_id = {$this->content_id}");
         throw new PAException(GROUP_REGISTRATION_TYPE_NOT_EXIST, "The registration type of group does not exist.It is a required field.");
     }
     if (!isset($this->is_moderated)) {
         Logger::log(GROUP_IS_MODERATED_NOT_EXIST, "No moderation_required set with collection_id = {$this->content_id}");
         throw new PAException(GROUP_IS_MODERATED_NOT_EXIST, "The moderation_required of group does not exist.It is a required field.");
     }
     if (!$this->is_active and $this->content_id) {
         Logger::log("Throwing Exception OPEREATION_NOT_PERMITTED");
         throw new PAException(OPERATION_NOT_PERMITTED, "Trying to save deleted content");
     }
     //if collection_id exists the update else insert
     if ($this->collection_id) {
         $user_type = Group::get_user_type($user_id, $this->collection_id);
         $access = $this->acl_object->acl_check('action', 'edit', 'users', $user_type, 'group', 'all');
         if (!$access) {
             throw new PAException(OPERATION_NOT_PERMITTED, 'You are not authorised to edit this group.');
         }
         $sql = "UPDATE {groups} SET access_type = ?, reg_type = ?, is_moderated = ?, category_id = ? , header_image = ? , header_image_action = ?,display_header_image = ? WHERE group_id = ?";
         try {
             $res = Dal::query($sql, array($this->access_type, $this->reg_type, $this->is_moderated, $this->category_id, $this->header_image, $this->header_image_action, $this->display_header_image, $this->collection_id));
             parent::save();
         } catch (Exception $e) {
             Dal::rollback();
             throw $e;
         }
     } else {
         //only registered user can create a group
         // This already has been taken care via session
         // we can add further modification if not use session user_id
         parent::save();
         try {
             $sql = "INSERT INTO {groups} (group_id, access_type, reg_type, is_moderated, category_id,header_image,header_image_action,display_header_image) VALUES (?, ?, ?, ?, ?,?,?,?)";
             $res = Dal::query($sql, array($this->collection_id, $this->access_type, $this->reg_type, $this->is_moderated, $this->category_id, $this->header_image, $this->header_image_action, $this->display_header_image));
             $this->created = time();
             $sql = "INSERT INTO {groups_users} (group_id, user_id, user_type, created) VALUES (?, ?, ?, ?)";
             $res = Dal::query($sql, array($this->collection_id, $this->author_id, OWNER, $this->created));
             foreach ($this->moderators as $mod) {
                 $sql = "INSERT INTO {groups_users} (group_id, user_id, user_type, created) VALUES (?, ?, ?, ?)";
                 $res = Dal::query($sql, array($this->collection_id, $mod, MODERATOR, $this->created));
             }
             Dal::commit();
         } catch (Exception $e) {
             Dal::rollback();
             throw $e;
         }
     }
     Logger::log("Exit: Group::save()");
     return $this->collection_id;
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:68,代码来源:Group.php

示例5: save

 /**
  * Saves object to databse.
  * @access protected.
  */
 protected function save()
 {
     if ($this->is_active == 0) {
         Logger::log(CONTENT_HAS_BEEN_DELETED, "Attempt to save a deleted content with content_id = {$this->content_id}");
         throw new PAException(CONTENT_HAS_BEEN_DELETED, "Object you are trying to save has been deleted");
     }
     Logger::log(" Enter: Content::save()", LOGGER_INFO);
     try {
         if (empty($this->active)) {
             $this->active = 1;
         }
         // before saving, check if content already exists or not.
         if ($this->content_id) {
             // UPDATE if exists
             if ($this->parent_collection_id != -1) {
                 //FIXME: do we need to make the distinction here?  Should probably always be able to set collection_id, even if -1.
                 $sql = "UPDATE {contents} SET title = ?, is_active = ?, body = ?, allow_comments =?, changed = ?, trackbacks = ?, collection_id = ?, is_html = ? WHERE content_id = ? AND is_active = ?";
                 $res = Dal::query($sql, array($this->title, $this->is_active, $this->body, $this->allow_comments, time(), $this->trackbacks, $this->parent_collection_id, $this->is_html, $this->content_id, $this->is_active));
             } else {
                 $sql = "UPDATE {contents} SET title = ?, is_active = ?, body = ?, allow_comments =?, changed = ?, trackbacks = ?, is_html = ? WHERE content_id = ? AND is_active = ?";
                 $res = Dal::query($sql, array($this->title, $this->is_active, $this->body, $this->allow_comments, time(), $this->trackbacks, $this->is_html, $this->content_id, $this->is_active));
             }
         } else {
             // get next ID for content.
             $this->content_id = Dal::next_id('Content');
             $this->created = time();
             $this->changed = $this->created;
             if (!$this->allow_comments) {
                 $this->allow_comments = 0;
             }
             $sql = "INSERT INTO {contents} (content_id, author_id, type, title, is_active, body, allow_comments, collection_id, created, changed, trackbacks, display_on, is_html) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
             $res = Dal::query($sql, array($this->content_id, $this->author_id, $this->type, $this->title, $this->is_active, $this->body, $this->allow_comments, $this->parent_collection_id, $this->created, $this->changed, $this->trackbacks, $this->display_on, $this->is_html));
         }
         if ($this->is_default_content == FALSE) {
             Content::save_recent_content($this->content_id, $this->type);
         }
         // if everything succeeded, commit
         Dal::commit();
     } catch (Exception $e) {
         Logger::log("Exception occurred inside Content::save(); rolling back", LOGGER_INFO);
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: Content::save()", LOGGER_INFO);
     return $this->content_id;
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:50,代码来源:Content.php

示例6: save_user_profile_fields

 /**
  * Generic function to save an entry in user_profile_data table on
  * the basis of user_id, field_type and field name.
  * @param user_data_array
  * @param array('field_type', ''field_name)
  */
 public function save_user_profile_fields($user_profile_data, $field_type, $field_name, $params = null)
 {
     Logger::log("Exit: function User::save_user_profile_fields");
     $sql = 'DELETE FROM {user_profile_data} WHERE user_id = ? AND field_type = ? AND field_name = ?';
     $data = array($this->user_id, $field_type, $field_name);
     if (count($params)) {
         foreach ($params as $key => $value) {
             $sql .= ' AND ' . $key . ' = ?';
             $data[] = $value;
         }
     }
     try {
         //Deleting the existing data from user_profile
         Dal::query($sql, $data);
         //Inserting new data to the user_profile
         foreach ($user_profile_data as $data) {
             $sql = 'INSERT into {user_profile_data} (user_id, field_name, field_value, field_type, field_perm, seq)  values (?, ?, ?, ?, ?, ?)';
             Dal::query($sql, $data);
         }
         //Commiting the changes to the database
         Dal::commit();
     } catch (PAException $e) {
         Logger::log("User::save_user_profile_fields function failed. Associate sql = {$sql}");
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: function User::save_user_profile_fields");
 }
开发者ID:CivicCommons,项目名称:people-aggregator,代码行数:34,代码来源:User.php

示例7: save

 public function save()
 {
     Logger::log("Enter: Event::save");
     // check for complete info
     if (empty($this->event_title)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: event_title is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Please supply an Event Title.');
     }
     $this->title = $this->event_title;
     if (empty($this->start_time)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: start_time is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Please specify the Start Time.');
     }
     if (empty($this->end_time)) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: end_time is empty", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Please specify the End Time.');
     }
     // serialize event_data for storage
     $event_data = "";
     if (!empty($this->event_data)) {
         $event_data = serialize($this->event_data);
     }
     // make end_time sane (can only be same or after start_time)
     if (strtotime($this->end_time) <= strtotime($this->start_time)) {
         $this->end_time = $this->start_time;
     }
     $this->author_id = $this->user_id;
     $this->body = $this->event_data['description'];
     // are we creating a new one?
     if (!$this->event_id) {
         /*
         if (empty($this->content_id)) {
             Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: content_id is empty", LOGGER_ERROR);
             throw new PAException(REQUIRED_PARAMETERS_MISSING, 'Content id is missing.');
         }
         */
         // do we have a real User set as owner?
         if (!User::user_exist((int) $this->user_id)) {
             Logger::log(" Throwing exception USER_NOT_FOUND | Message: User does not exist", LOGGER_ERROR);
             throw new PAException(USER_NOT_FOUND, 'User does not exist.');
         }
         // save a Content
         parent::save();
         $sql = "INSERT INTO events \n      (content_id, user_id, event_title, start_time, end_time, event_data) \n      VALUES (?, ?, ?, ?, ?, ?)";
         $data = array($this->content_id, $this->user_id, $this->event_title, $this->start_time, $this->end_time, $event_data);
     } else {
         // save as Content
         parent::save();
         $sql = "UPDATE {events} SET " . "event_title = ?, start_time = ?, end_time = ?, event_data = ? " . "WHERE event_id = ?";
         $data = array($this->event_title, $this->start_time, $this->end_time, $event_data, $this->event_id);
     }
     // write to DB
     try {
         Dal::query($sql, $data);
         if (!$this->event_id) {
             // newly created
             $this->event_id = Dal::insert_id();
         } else {
             // update any existing EventAssociations
             EventAssociation::update_assocs_for_event($this);
         }
         // Finally - commit our changes to the DB
         Dal::commit();
     } catch (PAException $e) {
         // roll back database operations and re-throw the exception
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: Event::save");
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:70,代码来源:Event.php

示例8: delete_video

 /**
   Adding function delete for deleting this 
   We are sending a request to the tekmedia server for deleting the content
   But at present we used Softdelete from our side
 */
 function delete_video($content_id)
 {
     Logger::log("Enter: TekVideo::delete_video()");
     if (empty($content_id)) {
         return true;
     }
     // for deleting this content, retrive all the information of that content
     $this->load($content_id);
     try {
         $video_id = $this->video_id;
         $sql = 'DELETE FROM {media_videos}
               WHERE content_id = ?';
         $data = array($this->content_id);
         Dal::query($sql, $data);
         // Content_deleted successfully from video table
         Content::delete_by_id($this->content_id);
         // Content deleted successfully from Content table
         $tekmedia_obj = new Tekmedia();
         $tekmedia_obj->delete_video_from_server($video_id);
         // Video deleted successfully from tekmedia server
         // all done - commit to database
         Dal::commit();
     } catch (PAException $e) {
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: TekVideo::delete_video()");
     return true;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:34,代码来源:TekVideo.php

示例9: save

 /**
  * Save the persona property data to the database.
  *
  * When creating a new persona property, set all the attributes for the 
  * property (except persona_property_id) and call save. Save will set
  * the persona_propety_id for the persona.
  */
 public function save()
 {
     Logger::log("Enter: function PersonaProperty::save");
     try {
         if (!$this->persona_id || !$this->name) {
             Logger::log("Throwing exception REQUIRED_PARAMETERS_MISSING | Message: Required parameters missing", LOGGER_ERROR);
             throw new PAException(REQUIRED_PARAMETERS_MISSING, "Required parameters missing");
         }
         if ($this->is_new) {
             $this->is_new = false;
             $this->persona_property_id = Dal::next_id("persona_properties");
             $sql = 'INSERT INTO {persona_properties} (parent_id, persona_id, name, content, content_type, content_hash, serial_number, last_update, category, viewer) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
             $data = array($this->parent_id, $this->persona_id, $this->name, $this->content, $this->content_type, $this->content_hash, $this->serial_number, $this->last_update, $this->category, $this->viewer);
             Dal::query($sql, $data);
         } else {
             $sql = "UPDATE {persona_properties} SET parent_id = ?, persona_id = ?, name = ?, content = ?, content_type = ?, content_hash = ?, serial_number = ?, last_update = ?, category = ?, viewer = ? WHERE persona_property_id = ?";
             $data = array($this->parent_id, $this->persona_id, $this->name, $this->content, $this->content_type, $this->content_hash, $this->serial_number, $this->last_update, $this->category, $this->viewer, $this->persona_property_id);
             Dal::query($sql, $data);
         }
         // All done - commit to database.
         Dal::commit();
     } catch (PAException $e) {
         Dal::rollback();
         throw $e;
     }
     Logger::log("Exit: function PersonaProperty::save");
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:34,代码来源:PersonaProperty.php

示例10: dirname

require_once dirname(__FILE__) . '/../../config.inc';
include_once "web/includes/page.php";
require_once "api/Roles/Roles.php";
require_once "api/User/User.php";
if ($_POST['uid']) {
    $msg = null;
    $user_id = (int) $_POST['uid'];
    $roles = $_REQUEST['role_extra'];
    foreach ($roles as $role_id => &$extra) {
        $_groups = array();
        $extra['user'] = (bool) $extra['user'];
        $extra['network'] = (bool) $extra['network'];
        foreach ($extra['groups'] as $key => $value) {
            if ($value) {
                $_groups[] = $key;
            }
        }
        $extra['groups'] = $_groups;
        try {
            $sql = 'UPDATE {users_roles} SET extra = ? WHERE user_id = ? AND role_id = ?';
            $data = array(serialize($extra), $user_id, $role_id);
            Dal::query($sql, $data);
            Dal::commit();
        } catch (PAException $e) {
            Dal::rollback();
            $msg = "Error: " . $e->getMessage();
            echo $msg;
        }
    }
    echo "Ok";
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:update_role_extra.php

示例11: save

 /**
  * Saves Group data to database
  * @access public
  * @param int $user_id ID of the user trying to save
  */
 public function save($user_id = NULL)
 {
     Logger::log('Enter: Group::save() | Args: \\$user_id = ' . $user_id);
     if (!empty($user_id)) {
         $this->author_id = $user_id;
     }
     if (empty($this->title)) {
         Logger::log('Exit: Group::save(). Title of the group is not specified.');
         throw new PAException(GROUP_NAME_NOT_EXIST, 'Title of the group is not specified');
     }
     if (!isset($this->access_type)) {
         Logger::log('Exit: Group::save(). Access type for the group is not specifed');
         throw new PAException(GROUP_ACCESS_TYPE_NOT_EXIST, 'Access type for the group is not specifed');
     }
     if (!isset($this->reg_type)) {
         Logger::log('Exit: Group::save(). User registration type is not specified for the group.');
         throw new PAException(GROUP_REGISTRATION_TYPE_NOT_EXIST, 'User registration type is not specified for the group.');
     }
     if (!isset($this->is_moderated)) {
         Logger::log('Exit: Group::save(). Moderation type is not specifed for the group.');
         throw new PAException(GROUP_IS_MODERATED_NOT_EXIST, 'Moderation type is not specifed for the group.');
     }
     if (!empty($this->extra)) {
         $this->extra = serialize($this->extra);
     }
     //if collection_id exists the update else insert
     if ($this->collection_id) {
         //       $user_type = Group::get_user_type ($this->author_id, $this->collection_id);
         //       $access = $this->acl_object->acl_check( 'action', 'edit', 'users', $user_type, 'group', 'all' );
         $access = PermissionsHandler::can_group_user(Group::get_owner_id((int) $this->collection_id), $this->collection_id, array('permissions' => 'manage_groups'));
         if (!$access) {
             throw new PAException(OPERATION_NOT_PERMITTED, 'You are not authorized to edit this group.');
         }
         $sql = "UPDATE {groups} SET access_type = ?, reg_type = ?, is_moderated = ?, category_id = ? , header_image = ? , header_image_action = ?, display_header_image = ?, group_type =?, extra=? WHERE group_id = ?";
         try {
             $res = Dal::query($sql, array($this->access_type, $this->reg_type, $this->is_moderated, $this->category_id, $this->header_image, $this->header_image_action, $this->display_header_image, $this->group_type, @$this->extra, $this->collection_id));
             parent::save();
         } catch (Exception $e) {
             Dal::rollback();
             throw $e;
         }
     } else {
         //only registered user can create a group
         // This already has been taken care via session
         // we can add further modification if not use session user_id
         try {
             parent::save();
             $sql = "INSERT INTO {groups} (group_id, access_type, reg_type, is_moderated, category_id, header_image, header_image_action, display_header_image, group_type, extra) VALUES (?, ?, ?, ?, ?,?,?,?, ?, ?)";
             $data = array($this->collection_id, $this->access_type, $this->reg_type, $this->is_moderated, $this->category_id, $this->header_image, $this->header_image_action, $this->display_header_image, $this->group_type, @$this->extra);
             $res = Dal::query($sql, $data);
             $this->created = time();
             $sql = "INSERT INTO {groups_users} (group_id, user_id, user_type, created) VALUES (?, ?, ?, ?)";
             $res = Dal::query($sql, array($this->collection_id, $this->author_id, OWNER, $this->created));
             foreach ($this->moderators as $mod) {
                 $sql = "INSERT INTO {groups_users} (group_id, user_id, user_type, created) VALUES (?, ?, ?, ?)";
                 $res = Dal::query($sql, array($this->collection_id, $mod, MODERATOR, $this->created));
             }
             Dal::commit();
             // setup extra permissions for group owner
             // so, we need to assign group admin role to group owner now:
             $role_extra = array('user' => false, 'network' => false, 'groups' => array($this->collection_id));
             $user_roles[] = array('role_id' => GROUP_ADMIN_ROLE, 'extra' => serialize($role_extra));
             $group_owner = new User();
             $group_owner->load($this->author_id);
             $group_owner->set_user_role($user_roles);
         } catch (Exception $e) {
             Dal::rollback();
             throw $e;
         }
     }
     Logger::log("Exit: Group::save()");
     return $this->collection_id;
 }
开发者ID:paragjagdale,项目名称:people-aggregator,代码行数:78,代码来源:Group.php


注:本文中的Dal::commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。