function store(&$pParamHash)
 {
     if ($this->verify($pParamHash)) {
         $this->mDb->StartTrans();
         if (parent::store($pParamHash)) {
             if ($this->mEditionId) {
                 $result = $this->mDb->associateUpdate(BIT_DB_PREFIX . "newsletters_editions", $pParamHash['edition_store'], array("edition_id" => $this->mEditionId));
             } else {
                 $pParamHash['edition_store']['content_id'] = $pParamHash['content_id'];
                 $result = $this->mDb->associateInsert(BIT_DB_PREFIX . "newsletters_editions", $pParamHash['edition_store']);
             }
             $this->mDb->CompleteTrans();
             $this->load();
         } else {
             $this->mDb->RollbackTrans();
         }
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 2
0
 /**
  * Store a Blog Post
  * @todo users_watches is a legacy package and needs refactoring
  */
 function store(&$pParamHash)
 {
     global $gBitSystem;
     $this->StartTrans();
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "blog_posts";
         // Send trackbacks recovering only successful trackbacks
         if (!empty($pParamHash['trackback'])) {
             $trackbacks = serialize($this->sendTrackbacks($pParamHash['trackback']));
         }
         if ($this->isValid()) {
             $locId = array("content_id" => $this->mContentId);
             $result = $this->mDb->associateUpdate($table, $pParamHash['post_store'], $locId);
         } else {
             $pParamHash['post_store']['content_id'] = $pParamHash['content_id'];
             if (@$this->verifyId($pParamHash['post_id'])) {
                 // if pParamHash['post_id'] is set, someone is requesting a particular post_id. Use with caution!
                 $pParamHash['post_store']['post_id'] = $pParamHash['post_id'];
             } else {
                 $pParamHash['post_store']['post_id'] = $this->mDb->GenID('blog_posts_post_id_seq');
             }
             $this->mPostId = $pParamHash['post_store']['post_id'];
             //store the new post
             $result = $this->mDb->associateInsert($table, $pParamHash['post_store']);
         }
         // let's reload to get a full mInfo hash which is needed below
         $this->load();
         // if blog_content_id, then map the post to the relative blogs
         if (!empty($pParamHash['blog_content_id'])) {
             $this->storePostMap($this->mInfo, $pParamHash['blog_content_id'], NULL, TRUE);
         }
         // Update post with trackbacks successfully sent
         // Can this be moved below into similar function below? -wjames5
         // this throws an error on site population because post_id is not defined in pParamHash - wjames5
         $query = "UPDATE `" . BIT_DB_PREFIX . "blog_posts` SET `trackbacks_from`=?, `trackbacks_to` = ? WHERE `post_id`=?";
         if (@BitBase::verifyId($pParamHash['post_id'])) {
             $this->mDb->query($query, array(serialize(array()), $trackbacks, (int) $pParamHash['post_id']));
         }
         if ($gBitSystem->isFeatureActive('users_watches')) {
             global $gBitUser, $gBitSmarty;
             if (isset($this->mInfo['blog_id']) && ($nots = $gBitUser->getEventWatches('blog_post', $this->mInfo['blog_id']))) {
                 foreach ($nots as $not) {
                     $gBitSmarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
                     $gBitSmarty->assign('mail_title', $this->mInfo['title']);
                     $gBitSmarty->assign('mail_blogid', $this->mInfo['blog_id']);
                     $gBitSmarty->assign('mail_postid', $this->mPostId);
                     $gBitSmarty->assign('mail_date', $gBitSystem->getUTCTime());
                     $gBitSmarty->assign('mail_user', $this->mInfo['login']);
                     $gBitSmarty->assign('mail_data', $this->mInfo['data']);
                     $gBitSmarty->assign('mail_hash', $not['hash']);
                     $foo = parse_url($_SERVER["REQUEST_URI"]);
                     $machine = httpPrefix() . $foo["path"];
                     $gBitSmarty->assign('mail_machine', $machine);
                     $parts = explode('/', $foo['path']);
                     if (count($parts) > 1) {
                         unset($parts[count($parts) - 1]);
                     }
                     $gBitSmarty->assign('mail_machine_raw', httpPrefix() . implode('/', $parts));
                     $mail_data = $gBitSmarty->fetch('bitpackage:blogs/user_watch_blog_post.tpl');
                     @mail($not['email'], tra('Blog post') . ' ' . $title, $mail_data, "From: " . $gBitSystem->getPrefence('site_sender_email') . "\r\nContent-type: text/plain;charset=utf-8\r\n");
                 }
             }
         }
         //is this nearly identical to the above and can they be consolodated? -wjames5
         // should this be $pParamHash['trackback'] or the above $pParamHash['trackbacks'] ? - xing
         if (!empty($pParamHash['trackbacks'])) {
             $query = "update `" . BIT_DB_PREFIX . "blog_posts` set `trackbacks_to`=? where `post_id`=?";
             $result = $this->mDb->query($query, array($trackbacks, $user_id, $post_id));
         }
         $this->CompleteTrans();
         $this->load();
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 3
0
 function store(&$pParamHash)
 {
     if ($this->verify($pParamHash)) {
         $overlayKey = $this->mOverlayType . '_id';
         $this->mDb->StartTrans();
         if (LibertyMime::store($pParamHash)) {
             if ($this->mOverlayId) {
                 if (!empty($pParamHash['overlay_store'])) {
                     // store the posted changes
                     $locId = array("content_id" => $this->mContentId);
                     $this->mDb->associateUpdate(BIT_DB_PREFIX . $this->mOverlayTable, $pParamHash['overlay_store'], $locId);
                 }
                 // if we have a set id we assume the mapping to the overlay set needs updating too
                 if (!empty($pParamHash['keychain_store']['set_id'])) {
                     $pParamHash['keychain_store'][$overlayKey] = $this->mOverlayId;
                     $this->mapToSet($pParamHash);
                 }
             } else {
                 $pParamHash['overlay_store']['content_id'] = $this->mContentId;
                 $pParamHash['overlay_store'][$overlayKey] = $this->mDb->GenID($this->mOverlaySeq);
                 $this->mDb->associateInsert(BIT_DB_PREFIX . $this->mOverlayTable, $pParamHash['overlay_store']);
                 // if its a new overlay we also get a set_id for the keychain and automaticallly associate it with a overlay set.
                 if (!empty($pParamHash['keychain_store']['set_id'])) {
                     $pParamHash['keychain_store'][$overlayKey] = $pParamHash['overlay_store'][$overlayKey];
                     $this->mapToSet($pParamHash);
                 }
             }
             $this->mDb->CompleteTrans();
             // re-query to confirm results
             $result = $this->load();
         } else {
             $this->mDb->RollbackTrans();
         }
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 4
0
 function storeComment(&$pParamHash)
 {
     $this->StartTrans();
     if ($this->verifyComment($pParamHash) && LibertyMime::store($pParamHash)) {
         if (!$this->mCommentId) {
             $this->mCommentId = $this->mDb->GenID('liberty_comment_id_seq');
             if (!empty($pParamHash['parent_id'])) {
                 $parentComment = new LibertyComment(NULL, $pParamHash['parent_id']);
             }
             $parent_sequence_forward = '';
             $parent_sequence_reverse = '';
             if (!empty($parentComment->mInfo['thread_forward_sequence'])) {
                 $parent_sequence_forward = $parentComment->mInfo['thread_forward_sequence'];
                 $parent_sequence_reverse = $parentComment->mInfo['thread_reverse_sequence'];
             }
             // if nesting level > 25 deep, put it on level 25
             if (strlen($parent_sequence_forward) > 10 * 24) {
                 $parent_sequence_forward = substr($parent_sequence_forward, 0, 10 * 24);
             }
             $this->mInfo['thread_forward_sequence'] = $parent_sequence_forward . sprintf("%09d.", $this->mCommentId);
             $this->mInfo['thread_reverse_sequence'] = strtr($parent_sequence_forward . sprintf("%09d.", $this->mCommentId), '0123456789', '9876543210');
             $sql = "INSERT INTO `" . BIT_DB_PREFIX . "liberty_comments` (`comment_id`, `content_id`, `parent_id`, `root_id`, `anon_name`, `thread_forward_sequence`, `thread_reverse_sequence`) VALUES (?,?,?,?,?,?,?)";
             $this->mDb->query($sql, array($this->mCommentId, $pParamHash['content_id'], $pParamHash['parent_id'], $pParamHash['root_id'], $pParamHash['anon_name'], $this->mInfo['thread_forward_sequence'], $this->mInfo['thread_reverse_sequence']));
             $this->mInfo['parent_id'] = $pParamHash['parent_id'];
             $this->mInfo['content_id'] = $pParamHash['content_id'];
             $this->mInfo['root_id'] = $pParamHash['root_id'];
             $this->mContentId = $pParamHash['content_id'];
         } else {
             $sql = "UPDATE `" . BIT_DB_PREFIX . "liberty_comments` SET `parent_id` = ?, `content_id`= ? WHERE `comment_id` = ?";
             $this->mDb->query($sql, array($pParamHash['parent_id'], $pParamHash['content_id'], $this->mCommentId));
             $this->mInfo['parent_id'] = $pParamHash['parent_id'];
             $this->mInfo['content_id'] = $pParamHash['content_id'];
             $this->mContentId = $pParamHash['content_id'];
         }
         $this->invokeServices('comment_store_function', $pParamHash);
     }
     $this->CompleteTrans();
     return count($this->mErrors) == 0;
 }
Esempio n. 5
0
 function store(&$pParamHash)
 {
     global $gBitSystem;
     $this->StartTrans();
     if ($this->verify($pParamHash) && parent::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "blogs";
         if ($this->isValid()) {
             $result = $this->mDb->associateUpdate($table, $pParamHash['blog_store'], array("blog_id" => $pParamHash['blog_id']));
         } else {
             // DEPRECATED - this looks stupid -wjames5
             //$pParamHash['blog_store']['posts'] = 0;
             $pParamHash['blog_store']['content_id'] = $this->mContentId;
             if (isset($pParamHash['blog_id']) && is_numeric($pParamHash['blog_id'])) {
                 // if pParamHash['blog_id'] is set, someone is requesting a particular blog_id. Use with caution!
                 $pParamHash['blog_store']['blog_id'] = $pParamHash['blog_id'];
             } else {
                 $pParamHash['blog_store']['blog_id'] = $this->mDb->GenID('blogs_blog_id_seq');
             }
             $this->mBlogId = $pParamHash['blog_store']['blog_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['blog_store']);
         }
         $this->CompleteTrans();
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 6
0
 /**
  * Store pigeonhole data
  * @param $pParamHash contains all data to store the pigeonholes
  * @param $pParamHash[title] title of the new pigeonhole
  * @param $pParamHash[edit] description of the pigeonhole
  * @param $pParamHash[members] array of content_ids that are associated with this pigeonhole
  * @param $pParamHash[root_structure_id] if this is set, it will add the pigeonhole to this structure. if it's not set, a new structure / top level pigeonhole is created
  * @param $pParamHash[parent_id] set the structure_id that will server as the parent in the structure
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  * @access public
  **/
 function store(&$pParamHash)
 {
     $this->mDb->StartTrans();
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "pigeonholes";
         // this really confusing, strange order way of saving items is due to strange behaviour of GenID
         // probably has to do with not null default nextval('public.liberty_structures_id_seq'::text)
         if (!empty($pParamHash['update'])) {
             if (!empty($pParamHash['pigeonhole_store'])) {
                 $result = $this->mDb->associateUpdate($table, $pParamHash['pigeonhole_store'], array("content_id" => $this->mContentId));
             }
             $pParamHash['structure_location_id'] = $this->mStructureId;
         } else {
             // update the pigeonhole_store and structure_store content_id with the one from LibertyMime::store()
             $pParamHash['structure_store']['content_id'] = $pParamHash['content_id'];
             $pParamHash['pigeonhole_store']['content_id'] = $pParamHash['content_id'];
             // we need to store the new structure node now
             global $gStructure;
             // create new object if needed
             if (empty($gStructure)) {
                 $gStructure = new LibertyStructure();
             }
             $pParamHash['structure_location_id'] = $gStructure->storeNode($pParamHash['structure_store']);
             // get the corrent structure_id
             // structure_id has to be done like this since it's screwed up in the schema
             $pParamHash['pigeonhole_store']['structure_id'] = $this->mDb->getOne("SELECT MAX( `structure_id` ) FROM `" . BIT_DB_PREFIX . "liberty_structures`");
             $result = $this->mDb->associateInsert($table, $pParamHash['pigeonhole_store']);
         }
         // store content items
         if (!empty($pParamHash['pigeonhole_members_store'])) {
             // remove items first
             $this->expungePigeonholeMember(array('parent_id' => $this->mContentId));
             if (!$this->insertPigeonholeMember($pParamHash['pigeonhole_members_store'])) {
                 $this->mErrors['store'] = 'The content could not be inserted into the respective categories.';
             }
         }
         $this->mDb->CompleteTrans();
         $this->load();
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 7
0
 /**
  * Store TreasuryItem
  *
  * @param array $pStoreHash contains all data to store the gallery
  * @param string $pStoreHash[title] title of the new upload
  * @param string $pStoreHash[edit] description of the upload
  * @param array $pStoreHash[galleryContentIds] (optional) Gallery Content IDs this item belongs to
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  * @access public
  **/
 function store(&$pStoreHash)
 {
     global $gBitUser;
     // make sure all the data is in order
     if ($this->verify($pStoreHash)) {
         // short hand
         $this->mDb->StartTrans();
         // if this is an update, we remove entries in the map table first
         if ($this->isValid()) {
             $this->expungeItemMap();
         }
         if (LibertyMime::store($pStoreHash)) {
             // ---------- Map store
             // update entries in the map
             foreach ($pStoreHash['map_store']['galleryContentIds'] as $gcid) {
                 $storeRow = array('gallery_content_id' => $gcid, 'item_content_id' => $pStoreHash['content_id']);
                 $this->mDb->associateInsert(BIT_DB_PREFIX . 'treasury_map', $storeRow);
             }
         }
         if (count($this->mErrors) == 0) {
             $this->mDb->CompleteTrans();
         } else {
             $this->mDb->RollbackTrans();
         }
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 8
0
 /**
  * store Any method named Store inherently implies data will be written to the database
  * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  * This is the ONLY method that should be called in order to store( create or update )an suggestion!
  * It is very smart and will figure out what to do for you. It should be considered a black box.
  * 
  * @param array $pParamHash hash of values that will be used to store the page
  * @access public
  * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function store(&$pParamHash)
 {
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $this->mDb->StartTrans();
         $table = BIT_DB_PREFIX . "suggestion_data";
         if ($this->mSuggestionId) {
             $locId = array("suggestion_id" => $pParamHash['suggestion_id']);
             $result = $this->mDb->associateUpdate($table, $pParamHash['suggestion_store'], $locId);
         } else {
             $pParamHash['suggestion_store']['content_id'] = $pParamHash['content_id'];
             if (@$this->verifyId($pParamHash['suggestion_id'])) {
                 // if pParamHash['suggestion_id'] is set, some is requesting a particular suggestion_id. Use with caution!
                 $pParamHash['suggestion_store']['suggestion_id'] = $pParamHash['suggestion_id'];
             } else {
                 $pParamHash['suggestion_store']['suggestion_id'] = $this->mDb->GenID('suggestion_data_id_seq');
             }
             $this->mSuggestionId = $pParamHash['suggestion_id'] = $pParamHash['suggestion_store']['suggestion_id'];
             if ($result = $this->mDb->associateInsert($table, $pParamHash['suggestion_store'])) {
                 // send an email notification to subscribers
                 // load up creator user in case user_id was forced and is not the same as gBitUser
                 $user = new BitUser($pParamHash['user_id']);
                 $user->load();
                 $userName = $user->getDisplayName();
                 $userEmail = $user->getField('email');
                 // Draft the message body:
                 $body = "/----- " . tra('A new suggestion was submitted.') . " -----/\n\n" . "Submitted by: \n" . $userName . "\n" . $userEmail . "\n\n" . "Title: \n" . $pParamHash['title'] . "\n\n" . "Megawatt Hours / Year: \n" . $pParamHash['suggestion_store']['mwh'] . "\n\n" . "Description: \n" . $pParamHash['edit'] . "\n\n" . "Sources: \n" . $pParamHash['suggestion_store']['sources'];
                 $msgHash = array('subject' => tra('New Suggestion') . ': ' . $pParamHash['title'], 'alt_message' => $body);
                 global $gSwitchboardSystem;
                 // register the sender to be able to access it
                 $gSwitchboardSystem->registerSender(SUGGESTION_PKG_TITLE, 'new suggestion');
                 // fire a notification
                 $gSwitchboardSystem->sendEvent(SUGGESTION_PKG_TITLE, 'new suggestion', $pParamHash['content_id'], $msgHash);
                 // cheating by accessing directly - remove the sender because access should be restricted
                 unset($gSwitchboardSystem->mSenders[SUGGESTION_PKG_TITLE]);
             }
         }
         // $this->storeRefs( $pParamHash );
         $this->mDb->CompleteTrans();
         $this->load();
     } else {
         $this->mErrors['store'] = 'Failed to save this suggestion.';
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 9
0
 /**
  * Any method named Store inherently implies data will be written to the database
  * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  * This is the ONLY method that should be called in order to store( create or update )an bitboard!
  * It is very smart and will figure out what to do for you. It should be considered a black box.
  *
  * @param array pParams hash of values that will be used to store the page
  *
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  *
  * @access public
  **/
 function store(&$pParamHash)
 {
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "boards";
         $this->StartTrans();
         if ($this->mBitBoardId) {
             $locId = array("board_id" => $pParamHash['board_id']);
             $result = $this->mDb->associateUpdate($table, $pParamHash['board_store'], $locId);
         } else {
             $pParamHash['board_store']['content_id'] = $pParamHash['content_id'];
             if (@$this->verifyId($pParamHash['board_id'])) {
                 // if pParamHash['board_id'] is set, some is requesting a particular board_id. Use with caution!
                 $pParamHash['board_store']['board_id'] = $pParamHash['board_id'];
             } else {
                 $pParamHash['board_store']['board_id'] = $this->mDb->GenID('boards_board_id_seq');
             }
             $this->mBitBoardId = $pParamHash['board_store']['board_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['board_store']);
             $result = $this->mDb->associateInsert(BIT_DB_PREFIX . "boards_map", array('board_content_id' => $pParamHash['board_store']['content_id'], 'topic_content_id' => $pParamHash['board_store']['content_id']));
             if (!empty($pParamHash['boards_mailing_list'])) {
                 global $gBitSystem, $gBitUser;
                 require_once UTIL_PKG_PATH . 'mailman_lib.php';
                 if ($gBitSystem->getConfig('boards_sync_mail_server')) {
                     if (!($error = mailman_newlist(array('listname' => $pParamHash['boards_mailing_list'], 'listhost' => $gBitSystem->getConfig('boards_email_host', $gBitSystem->getConfig('kernel_server_name')), 'admin-password' => $pParamHash['boards_mailing_list_password'], 'listadmin-addr' => $gBitUser->getField('email'))))) {
                         $this->storePreference('boards_mailing_list', !empty($pParamHash['boards_mailing_list']) ? $pParamHash['boards_mailing_list'] : NULL);
                         $this->storePreference('boards_mailing_list_password', $pParamHash['boards_mailing_list_password']);
                         // Subscribe the owner
                         mailman_addmember($this->getPreference('boards_mailing_list'), $gBitUser->getField('email'));
                         // If we have an inbox then subscribe it as a moderator
                         if ($this->getBoardSyncInbox()) {
                             mailman_addmember($this->getPreference('boards_mailing_list'), $this->getBoardSyncInbox());
                             mailman_setmoderator($this->getPreference('boards_mailing_list'), $this->getBoardSyncInbox());
                         }
                         $this->storePreference('board_sync_list_address', $this->getBoardMailingList());
                     } else {
                         $this->mErrors['mailing_list'] = $error;
                     }
                 }
             }
         }
         if (count($this->mErrors) == 0) {
             $this->CompleteTrans();
             $this->load();
         } else {
             $this->mDb->RollbackTrans();
             $this->mContentId = NULL;
             $this->mBitBoardId = NULL;
         }
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 10
0
 /**
  * This is the ONLY method that should be called in order to store (create or update) a wiki page!
  * It is very smart and will figure out what to do for you. It should be considered a black box.
  *
  * @param array pParams hash of values that will be used to store the page
  *
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  *
  * @access public
  **/
 function store(&$pParamHash)
 {
     $this->StartTrans();
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $pParamHash['page_store']['wiki_page_size'] = !empty($pParamHash['edit']) ? strlen($pParamHash['edit']) : 0;
         $table = BIT_DB_PREFIX . "wiki_pages";
         if ($this->verifyId($this->mPageId)) {
             $result = $this->mDb->associateUpdate($table, $pParamHash['page_store'], array("page_id" => $this->mPageId));
         } else {
             $pParamHash['page_store']['content_id'] = $pParamHash['content_id'];
             if (@$this->verifyId($pParamHash['page_id'])) {
                 // if pParamHash['page_id'] is set, some is requesting a particular page_id. Use with caution!
                 $pParamHash['page_store']['page_id'] = $pParamHash['page_id'];
             } else {
                 $pParamHash['page_store']['page_id'] = $this->mDb->GenID('wiki_pages_page_id_seq');
             }
             $this->mPageId = $pParamHash['page_store']['page_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['page_store']);
         }
         // Access new data for notifications
         $this->load();
         if (isset($mailEvents)) {
             global $notificationlib, $gBitUser, $gBitSystem, $gBitSmarty;
             include_once KERNEL_PKG_PATH . 'notification_lib.php';
             $notificationlib->post_content_event($this->mContentId, $this->mInfo['content_type_guid'], 'wiki', $this->mInfo['title'], $this->mInfo['modifier_user'], $this->mInfo['edit_comment'], $this->mInfo['data']);
             if ($gBitSystem->isFeatureActive('users_watches')) {
                 $nots = $gBitUser->get_event_watches('wiki_page_changed', $this->mPageId);
                 foreach ($nots as $not) {
                     #						if ($wiki_watch_editor != 'y' && $not['user_id'] == $user)
                     #							break;
                     $gBitSmarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
                     $gBitSmarty->assign('mail_page', $this->mInfo['title']);
                     $gBitSmarty->assign('mail_date', $gBitSystem->getUTCTime());
                     $gBitSmarty->assign('mail_user', $this->mInfo['modifier_user']);
                     $gBitSmarty->assign('mail_comment', $this->mInfo['edit_comment']);
                     $gBitSmarty->assign('mail_last_version', $this->mInfo['version'] - 1);
                     $gBitSmarty->assign('mail_data', $this->mInfo['data']);
                     $gBitSmarty->assign('mail_hash', $not['hash']);
                     $foo = parse_url($_SERVER["REQUEST_URI"]);
                     $machine = httpPrefix();
                     $gBitSmarty->assign('mail_machine', $machine);
                     $parts = explode('/', $foo['path']);
                     if (count($parts) > 1) {
                         unset($parts[count($parts) - 1]);
                     }
                     $gBitSmarty->assign('mail_machine_raw', httpPrefix() . implode('/', $parts));
                     $gBitSmarty->assign('mail_pagedata', $this->mInfo['data']);
                     $mail_data = $gBitSmarty->fetch('bitpackage:wiki/user_watch_wiki_page_changed.tpl');
                     $email_to = $not['email'];
                     @mail($email_to, tra('Wiki page') . ' ' . $this->mInfo['title'] . ' ' . tra('changed'), $mail_data, "From: " . $gBitSystem->getConfig('site_sender_email') . "\r\nContent-type: text/plain;charset=utf-8\r\n");
                 }
             }
         }
     }
     $this->CompleteTrans();
     return count($this->mErrors) == 0;
 }
Esempio n. 11
0
 function store(&$pParamHash)
 {
     global $gBitSystem;
     $this->mDb->StartTrans();
     // verify
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         // store remotely
         /* note: we store remotely first because in new cases we need to get salsa's key identifiers */
         if ($this->storeSalsaAction($pParamHash)) {
             // then we store the content
             if ($this->verifyActionContent($pParamHash) && $this->storeSalsaActionContent($pParamHash)) {
                 // and content detail
                 if ($this->verifyActionContentDetail($pParamHash) && $this->storeSalsaActionContentDetail($pParamHash)) {
                     // and content detail
                     if ($this->verifyTargets($pParamHash) && $this->storeSalsaTargets($pParamHash)) {
                         // sync locally
                         // store the action object
                         $table = BIT_DB_PREFIX . "diasalsa_actions";
                         // update existing
                         if ($this->isValid()) {
                             $id = array("content_id" => $this->mContentId);
                             $result = $this->mDb->associateUpdate($table, $pParamHash['action_store'], $id);
                             // store new
                         } else {
                             $pParamHash['action_store']['content_id'] = $pParamHash['content_id'];
                             // key_id comes from diasalsa key param
                             $pParamHash['action_store']['key_id'] = $pParamHash['key_id'];
                             if (@$this->verifyId($pParamHash['action_id'])) {
                                 // if pParamHash['action_id'] is set, someone is requesting a particular action_id. Use with caution!
                                 $pParamHash['action_store']['action_id'] = $pParamHash['action_id'];
                             } else {
                                 $pParamHash['action_store']['action_id'] = $this->mDb->GenID('diasalsa_action_id_seq');
                             }
                             $this->mActionId = $pParamHash['action_store']['action_id'];
                             //store the new action
                             $result = $this->mDb->associateInsert($table, $pParamHash['action_store']);
                             //if its new we need to store in salsa AGAIN because we need to store the redirect url to get the user back to bw
                             $this->verify($pParamHash);
                             $this->storeSalsaAction($pParamHash);
                             // store the action content detail ref
                             // we only store once when new since its just a one to one map
                             // if ever want to support more than one content detail then this is one of
                             // many things that would have to change/be enhanced
                             // yes, f*****g verify again
                             if ($this->verifyActionContentMap($pParamHash)) {
                                 $table2 = BIT_DB_PREFIX . "diasalsa_action_content_map";
                                 $result2 = $this->mDb->associateInsert($table2, $pParamHash['action_content_map_store']);
                             } else {
                                 // something is f****d up so at least keep our database clean
                                 $this->mDb->RollbackTrans();
                             }
                         }
                         // if we have content to link do it
                         if ($this->verifyLinkContent($pParamHash)) {
                             $this->linkContentMixed($pParamHash);
                         }
                         // done
                         $this->mDb->CompleteTrans();
                     } else {
                         // remote storage of targets fail rollback sql transaction
                         $this->mDb->RollbackTrans();
                     }
                 } else {
                     // remote storage of action content detail fail rollback sql transaction
                     $this->mDb->RollbackTrans();
                 }
             } else {
                 // remote storage of action content fail rollback sql transaction
                 $this->mDb->RollbackTrans();
             }
         } else {
             // remote storage of action fail rollback sql transaction
             $this->mDb->RollbackTrans();
         }
     }
     return count($this->mErrors) == 0;
 }
 /**
  * store Any method named Store inherently implies data will be written to the database
  * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  * This is the ONLY method that should be called in order to store( create or update )an energymeasures!
  * It is very smart and will figure out what to do for you. It should be considered a black box.
  * 
  * @param array $pParamHash hash of values that will be used to store the page
  * @access public
  * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function store(&$pParamHash)
 {
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $this->mDb->StartTrans();
         $table = BIT_DB_PREFIX . "energymeasures_data";
         if ($this->mEnergyMeasuresId) {
             $locId = array("energymeasure_id" => $pParamHash['energymeasure_id']);
             $result = $this->mDb->associateUpdate($table, $pParamHash['energymeasures_store'], $locId);
         } else {
             $pParamHash['energymeasures_store']['content_id'] = $pParamHash['content_id'];
             if (@$this->verifyId($pParamHash['energymeasure_id'])) {
                 // if pParamHash['energymeasure_id'] is set, some is requesting a particular energymeasure_id. Use with caution!
                 $pParamHash['energymeasures_store']['energymeasure_id'] = $pParamHash['energymeasure_id'];
             } else {
                 $pParamHash['energymeasures_store']['energymeasure_id'] = $this->mDb->GenID('energymeasures_data_id_seq');
             }
             $this->mEnergyMeasuresId = $pParamHash['energymeasures_store']['energymeasure_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['energymeasures_store']);
         }
         $this->mDb->CompleteTrans();
         $this->load();
     } else {
         $this->mErrors['store'] = 'Failed to save this energymeasures.';
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 13
0
 /**
  * storeUserImage
  *
  * @param array $pStorageHash
  * @param string $pType
  * @access public
  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function storeUserImage(&$pStorageHash, $pType = 'portrait')
 {
     if ($this->isValid() && count($pStorageHash)) {
         // don't do the content thing
         $pStorageHash['skip_content_store'] = TRUE;
         // setup the hash for central storage functions
         $pStorageHash['no_perm_check'] = TRUE;
         $pStorageHash['_files_override'][$pType] = $pStorageHash['upload'];
         $pStorageHash['_files_override'][$pType]['max_width'] = constant(strtoupper($pType) . "_MAX_DIM");
         $pStorageHash['_files_override'][$pType]['max_height'] = constant(strtoupper($pType) . "_MAX_DIM");
         $pStorageHash['_files_override'][$pType]['attachment_id'] = !empty($this->mInfo["{$pType}_attachment_id"]) ? $this->mInfo["{$pType}_attachment_id"] : NULL;
         $pStorageHash['_files_override'][$pType]['user_id'] = $this->mUserId;
         if (LibertyMime::store($pStorageHash)) {
             $file = $pStorageHash['upload_store']['files'][$pType];
             if (empty($this->mInfo["{$pType}_attachment_id"]) || $this->mInfo["{$pType}_attachment_id"] != $file['attachment_id']) {
                 $query = "UPDATE `" . BIT_DB_PREFIX . "users_users` SET `{$pType}_attachment_id` = ? WHERE `user_id`=?";
                 $result = $this->mDb->query($query, array($file['attachment_id'], $this->mUserId));
                 $this->mInfo["{$pType}_attachment_id"] = $file['attachment_id'];
                 $pStorageHash["{$pType}_file_name"] = $file['upload']['dest_branch'];
             }
         } else {
             $this->mErrors["{$pType}_file"] = 'File ' . $pStorageHash['upload_store']['files'][$pType]['name'] . ' could not be stored.';
         }
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 14
0
 function store(&$pParamHash)
 {
     global $gBitSystem, $gLibertySystem;
     if ($this->verifyImageData($pParamHash)) {
         // Save the current attachment ID for the image attached to this FisheyeImage so we can
         // delete it after saving the new one
         if (!empty($this->mInfo['attachment_id']) && !empty($pParamHash['_files_override'][0])) {
             $currentImageAttachmentId = $this->mInfo['attachment_id'];
             $pParamHash['attachment_id'] = $currentImageAttachmentId;
         } else {
             $currentImageAttachmentId = NULL;
         }
         // we have already done all the permission checking needed for this user to upload an image
         $pParamHash['no_perm_check'] = TRUE;
         $this->StartTrans();
         $pParamHash['thumbnail'] = !$gBitSystem->isFeatureActive('liberty_offline_thumbnailer');
         if (LibertyMime::store($pParamHash)) {
             if ($currentImageAttachmentId && $currentImageAttachmentId != $this->mInfo['attachment_id']) {
                 $this->expungeAttachment($currentImageAttachmentId);
             }
             // get storage format back from LibertyMime
             $this->mContentId = $pParamHash['content_id'];
             $this->mInfo['content_id'] = $this->mContentId;
             if (!empty($this->mInfo['source_file']) && file_exists($this->getSourceFile())) {
                 $imageDetails = $this->getImageDetails($this->getSourceFile());
             } else {
                 $imageDetails = NULL;
             }
             if (!$imageDetails) {
                 $imageDetails['width'] = !empty($this->mInfo['width']) ? $this->mInfo['width'] : NULL;
                 $imageDetails['height'] = !empty($this->mInfo['height']) ? $this->mInfo['height'] : NULL;
             }
             if ($this->imageExistsInDatabase()) {
                 $sql = "UPDATE `" . BIT_DB_PREFIX . "fisheye_image`\n\t\t\t\t\t\t\tSET `content_id` = ?, `width` = ?, `height` = ?\n\t\t\t\t\t\t\tWHERE `image_id` = ?";
                 $bindVars = array($this->mContentId, $imageDetails['width'], $imageDetails['height'], $this->mImageId);
             } else {
                 $this->mImageId = defined('LINKED_ATTACHMENTS') ? $this->mContentId : $this->mDb->GenID('fisheye_image_id_seq');
                 $this->mInfo['image_id'] = $this->mImageId;
                 $sql = "INSERT INTO `" . BIT_DB_PREFIX . "fisheye_image` (`image_id`, `content_id`, `width`, `height`) VALUES (?,?,?,?)";
                 $bindVars = array($this->mImageId, $this->mContentId, $imageDetails['width'], $imageDetails['height']);
             }
             $rs = $this->mDb->query($sql, $bindVars);
             // check to see if we need offline thumbnailing
             if ($gBitSystem->isFeatureActive('liberty_offline_thumbnailer')) {
                 $resize = !empty($pParamHash['resize']) ? (int) $pParamHash['resize'] : NULL;
                 $this->generateThumbnails($resize);
             } else {
                 if (!empty($pParamHash['resize']) && is_numeric($pParamHash['resize'])) {
                     $this->resizeOriginal($pParamHash['resize']);
                 }
             }
             $this->CompleteTrans();
         } else {
             $this->mDb->RollbackTrans();
         }
         $this->clearFromCache();
     } else {
         $this->mErrors[] = "There were errors while attempting to save this gallery image";
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 15
0
 /**
  * Any method named Store inherently implies data will be written to the database
  * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  * This is the ONLY method that should be called in order to store( create or update )an events!
  * It is very smart and will figure out what to do for you. It should be considered a black box.
  *
  * @param array pParams hash of values that will be used to store the page
  *
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  *
  * @access public
  **/
 function store(&$pParamHash)
 {
     $this->StartTrans();
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "events";
         $prefChecks = array('show_start_time', 'show_end_time');
         foreach ($prefChecks as $var) {
             if (isset($pParamHash['events_prefs_store'][$var])) {
                 $this->storePreference($var, $pParamHash['events_prefs_store'][$var]);
             } else {
                 $this->storePreference($var);
             }
         }
         if ($this->mEventsId) {
             $result = $this->mDb->associateUpdate($table, $pParamHash['events_store'], array('events_id' => $pParamHash['events_id']));
             $this->updateEventsOn($pParamHash);
         } else {
             $pParamHash['events_store']['content_id'] = $pParamHash['content_id'];
             if (@$this->verifyId($pParamHash['events_id'])) {
                 // if pParamHash['events_id'] is set, some is requesting a particular events_id. Use with caution!
                 $pParamHash['events_store']['events_id'] = $pParamHash['events_id'];
             } else {
                 $pParamHash['events_store']['events_id'] = $this->mDb->GenID('events_events_id_seq');
             }
             $this->mEventsId = $pParamHash['events_store']['events_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['events_store']);
             $this->insertEventsOn($pParamHash);
         }
         $this->CompleteTrans();
         $this->load();
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 16
0
 /**
  * @param array $pParamHash hash of values that will be used to store the page
  * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 public function store(&$pParamHash = NULL)
 {
     if (empty($this->mChildPkgName)) {
         $this->mErrors['store'] = "Configuration error, don't know package name";
         return FALSE;
     }
     // If no updated data hash passed in fake pParamHash from objects existing data
     if ($pParamHash == NULL) {
         $pParamHash = $this->fakeStoreHash();
     }
     $childStore = $this->mChildPkgName . '_store';
     if ($this->verifyData($pParamHash, $childStore) && parent::store($pParamHash)) {
         $this->mDb->StartTrans();
         if ($this->mId) {
             if (isset($pParamHash[$this->mChildIdName]) && $pParamHash[$this->mChildIdName] != $this->mId) {
                 $this->mErrors['store'] = "Attempting to change id of existing data is not supported.";
                 return FALSE;
             }
             $locId = array($this->mChildIdName => $this->mId);
             $result = $this->mDb->associateUpdate($this->mFormTbl, $pParamHash[$childStore], $locId);
         } else {
             $pParamHash[$childStore][$this->mChildIdName] = $this->mDb->GenID($this->mFormSeq);
             $pParamHash[$childStore]['content_id'] = $pParamHash['content_id'];
             $result = $this->mDb->associateInsert($this->mFormTbl, $pParamHash[$childStore]);
             // result checking ... nah, why bother !?
             $this->mId = $pParamHash[$childStore][$this->mChildIdName];
         }
         if (!empty($pParamHash[$childStore . '_multiple'])) {
             foreach ($pParamHash[$childStore . '_multiple'] as $multiTbl => $bindvarray) {
                 // first remove any existing entries
                 $query = "DELETE FROM `" . BIT_DB_PREFIX . $multiTbl . "` WHERE (`" . $this->mChildIdName . "` = ?) ";
                 $result = $this->mDb->query($query, array($this->mId));
                 // then insert any new or modified values
                 foreach ($bindvarray as $bindvar) {
                     $bindvar[$this->mChildIdName] = $this->mId;
                     // has to happen here for fresh creates
                     $result = $this->mDb->associateInsert(BIT_DB_PREFIX . $multiTbl, $bindvar);
                 }
             }
         }
         $this->mDb->CompleteTrans();
         $this->load();
     } else {
         $this->mErrors['store'] = "Failed to save the {$this->mChildPkgName} data.";
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 17
0
 /**
  * Any method named Store inherently implies data will be written to the database
  * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  * This is the ONLY method that should be called in order to store( create or update )an stencil!
  * It is very smart and will figure out what to do for you. It should be considered a black box.
  *
  * @param array pParams hash of values that will be used to store the page
  *
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  *
  * @access public
  **/
 function store(&$pParamHash)
 {
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "stencils";
         $this->mDb->StartTrans();
         if ($this->mStencilId) {
             $locId = array("stencil_id" => $pParamHash['stencil_id']);
             $result = $this->mDb->associateUpdate($table, $pParamHash['stencil_store'], $locId);
         } else {
             $pParamHash['stencil_store']['content_id'] = $pParamHash['content_id'];
             if (@$this->verifyId($pParamHash['stencil_id'])) {
                 // if pParamHash['stencil_id'] is set, some is requesting a particular stencil_id. Use with caution!
                 $pParamHash['stencil_store']['stencil_id'] = $pParamHash['stencil_id'];
             } else {
                 $pParamHash['stencil_store']['stencil_id'] = $this->mDb->GenID('stencils_stencil_id_seq');
             }
             $this->mStencilId = $pParamHash['stencil_store']['stencil_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['stencil_store']);
         }
         $this->mDb->CompleteTrans();
         $this->load();
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 18
0
 /**
  * @param array pParamHash hash of values that will be used to store the group
  * be sure to pass by reference in case we need to make modifcations to the hash
  *
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  *
  * @access public
  **/
 function store(&$pParamHash)
 {
     global $gBitUser, $gBitSystem;
     // Merge down groups prefix. This is a hack but is faster
     // than rewriting verify to use things from the "group" prefix.
     // @TODO: Rewire verify() to pull all data from 'group' prefix
     if (!empty($pParamHash['group'])) {
         $pParamHash = array_merge($pParamHash, $pParamHash['group']);
     }
     $this->mDb->StartTrans();
     // Verify and then store group and content.
     if ($this->verify($pParamHash) && $gBitUser->storeGroup($pParamHash) && LibertyMime::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "groups";
         if ($this->mGroupId) {
             // editing an existing group
             $locId = array("group_id" => $pParamHash['group_id']);
             $result = $this->mDb->associateUpdate($table, $pParamHash['group_pkg_store'], $locId);
         } else {
             // new group
             $pParamHash['group_pkg_store']['content_id'] = $pParamHash['content_id'];
             $pParamHash['group_pkg_store']['group_id'] = $pParamHash['group_store']['group_id'];
             $this->mGroupId = $pParamHash['group_store']['group_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['group_pkg_store']);
             // Make sure this user is in the group
             $gBitUser->addUserToGroup($gBitUser->mUserId, $this->mGroupId);
             // Restore the group in users table to update the home link now that we have a group id
             $pParamHash['home'] = GROUP_PKG_URL . "index.php?group_id=" . $this->mGroupId;
             // Restore the home now
             $gBitUser->storeGroup($pParamHash);
             // Autogenerate a board for this group
             if ($gBitSystem->isPackageActive('boards')) {
                 require_once BOARDS_PKG_PATH . 'BitBoard.php';
                 $board = new BitBoard();
                 $boardHash = array("title" => $pParamHash['title'] . " " . tra('Forum'), "data" => tra('Message board for the ') . $pParamHash['title'] . " " . tra('Group'), 'boards_mailing_list' => preg_replace('/[^a-z0-9]/', '', strtolower($pParamHash['content_store']['title'])), 'boards_mailing_list_password' => substr(md5(rand()), 0, 8), 'group' => array('bypass_map_required' => TRUE));
                 if ($board->store($boardHash)) {
                     $this->linkContent($board->mInfo);
                     $this->mBoardObj =& $board;
                 } else {
                     $this->mErrors['board'] = tra('Unknown error while creating the board.');
                     $this->mErrors = array_merge($this->mErrors, $board->mErrors);
                 }
             }
         }
         // @TODO: This should be in boards
         if ($gBitSystem->isPackageActive('boards')) {
             if (empty($board) || !is_object($board)) {
                 $board = $this->getBoard();
             }
             // pass moderate messages selection on to our group board
             $modComments = $pParamHash['group_pkg_store']['mod_msgs'] == 'y' ? $pParamHash['group_pkg_store']['mod_msgs'] : NULL;
             $board->storePreference('moderate_comments', $modComments);
             $list = $board->getPreference('boards_mailing_list');
             if (!empty($list)) {
                 require_once UTIL_PKG_PATH . 'mailman_lib.php';
                 mailman_setmoderated($list, $modComments == 'y' ? 1 : 0);
             }
         }
         if (count($this->mErrors) == 0) {
             $this->mDb->CompleteTrans();
             $this->load();
         } else {
             $this->mDb->RollbackTrans();
             // Clear out the IDs
             $this->mContentId = NULL;
             $this->mGroupId = NULL;
         }
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 19
0
 function store(&$pParamHash)
 {
     if ($this->verify($pParamHash)) {
         $this->mDb->StartTrans();
         if (parent::store($pParamHash)) {
             if ($this->mGmapId) {
                 //				vd($pParamHash['gmap_store']);
                 //				die;
                 // store the posted changes
                 $this->mDb->associateUpdate(BIT_DB_PREFIX . "gmaps", $pParamHash['gmap_store'], array("gmap_id" => $this->mGmapId));
             } else {
                 $pParamHash['gmap_store']['content_id'] = $this->mContentId;
                 $pParamHash['gmap_store']['gmap_id'] = $this->mDb->GenID('gmaps_gmap_id_seq');
                 $this->mDb->associateInsert(BIT_DB_PREFIX . "gmaps", $pParamHash['gmap_store']);
             }
             $this->mDb->CompleteTrans();
             // re-query to confirm results
             $result = $this->load(FALSE);
         } else {
             $this->mDb->RollbackTrans();
         }
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 20
0
 /**
  * Store article data after submission
  * @param array pParamHash of values that will be used to store the page
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  * @access public
  **/
 public function store(&$pParamHash)
 {
     global $gBitSystem;
     $this->mDb->StartTrans();
     if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) {
         $table = BIT_DB_PREFIX . "articles";
         if ($this->isValid()) {
             $result = $this->mDb->associateUpdate($table, $pParamHash['article_store'], array("article_id" => $this->mArticleId));
         } else {
             $pParamHash['article_store']['content_id'] = $pParamHash['content_id'];
             if (isset($pParamHash['article_id']) && is_numeric($pParamHash['article_id'])) {
                 // if pParamHash['article_id'] is set, someone is requesting a particular article_id. Use with caution!
                 $pParamHash['article_store']['article_id'] = $pParamHash['article_id'];
             } else {
                 $pParamHash['article_store']['article_id'] = $this->mDb->GenID('articles_article_id_seq');
             }
             $this->mArticleId = $pParamHash['article_store']['article_id'];
             $result = $this->mDb->associateInsert($table, $pParamHash['article_store']);
         }
         $this->mDb->CompleteTrans();
         $this->load();
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 21
0
 /**
  * store Any method named Store inherently implies data will be written to the database
  * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
  * This is the ONLY method that should be called in order to store( create or update )an sample!
  * It is very smart and will figure out what to do for you. It should be considered a black box.
  * 
  * @param array $pParamHash hash of values that will be used to store the page
  * @access public
  * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function store(&$pParamHash)
 {
     if ($this->verify($pParamHash)) {
         $this->mDb->StartTrans();
         if (LibertyMime::store($pParamHash)) {
             $table = BIT_DB_PREFIX . "sample_data";
             if ($this->mSampleId) {
                 $locId = array("sample_id" => $this->mSampleId);
                 $this->mDb->associateUpdate($table, $pParamHash['sample_store'], $locId);
             } else {
                 $pParamHash['sample_store']['content_id'] = $pParamHash['content_id'];
                 $pParamHash['sample_store']['sample_id'] = $this->mDb->GenID('sample_data_id_seq');
                 $this->mSampleId = $pParamHash['sample_store']['sample_id'];
                 $this->mDb->associateInsert($table, $pParamHash['sample_store']);
             }
         } else {
             $this->mErrors['store'] = 'Could not store Liberty data to save this sample.';
         }
         if (!$this->mDb->CompleteTrans()) {
             $this->mErrors['store'] = 'Sample store: ' . $this->mDb->ErrorMsg();
         }
         $this->load();
     } else {
         $this->mErrors['store'] = 'Could not verify data to save this sample.';
     }
     return count($this->mErrors) == 0;
 }
Esempio n. 22
0
 function store(&$pParamHash)
 {
     // we have already done all the permission checking needed for this user to upload an image
     $pParamHash['no_perm_check'] = TRUE;
     $this->StartTrans();
     if (CommerceProduct::verify($pParamHash) && LibertyMime::store($pParamHash)) {
         if (isset($pParamHash['pID'])) {
             $this->mProductsId = zen_db_prepare_input($pParamHash['pID']);
         }
         if ($this->isValid()) {
             $action = 'update_product';
             $this->mDb->associateUpdate(TABLE_PRODUCTS, $pParamHash['product_store'], array('products_id' => $this->mProductsId));
         } else {
             $pParamHash['product_store']['content_id'] = $pParamHash['content_id'];
             $action = 'insert_product';
             $this->mDb->associateInsert(TABLE_PRODUCTS, $pParamHash['product_store']);
             $this->mProductsId = zen_db_insert_id(TABLE_PRODUCTS, 'products_id');
             $this->mDb->query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " ( `products_id`, `categories_id` ) values (?,?)", array($this->mProductsId, $pParamHash['product_store']['master_categories_id']));
         }
         $languages = zen_get_languages();
         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
             $language_id = $languages[$i]['id'];
             $bindVars = array();
             if (!empty($pParamHash['products_name'][$language_id])) {
                 $bindVars['products_name'] = substr(zen_db_prepare_input($pParamHash['products_name'][$language_id]), 0, 64);
             }
             if (!empty($pParamHash['products_description'][$language_id])) {
                 $bindVars['products_description'] = zen_db_prepare_input($pParamHash['products_description'][$language_id]);
             }
             if (!empty($pParamHash['products_url'][$language_id])) {
                 $bindVars['products_url'] = substr(zen_db_prepare_input($pParamHash['products_url'][$language_id]), 0, 255);
             }
             if ($action == 'insert_product') {
                 $bindVars['products_id'] = $this->mProductsId;
                 $bindVars['language_id'] = $language_id;
                 $this->mDb->associateInsert(TABLE_PRODUCTS_DESCRIPTION, $bindVars);
             } elseif ($action == 'update_product') {
                 if (!empty($bindVars)) {
                     $query = "UPDATE " . TABLE_PRODUCTS_DESCRIPTION . " SET `" . implode(array_keys($bindVars), '`=?, `') . '`=?' . " WHERE `products_id` =? AND `language_id`=?";
                     $bindVars['products_id'] = $this->mProductsId;
                     $bindVars['language_id'] = $language_id;
                     $this->mDb->query($query, $bindVars);
                 }
             }
         }
         // add meta tags
         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
             $language_id = $languages[$i]['id'];
             $bindVars = array();
             if (!empty($pParamHash['metatags_title'][$language_id])) {
                 $bindVars['metatags_title'] = zen_db_prepare_input($pParamHash['metatags_title'][$language_id]);
             }
             if (!empty($pParamHash['metatags_keywords'][$language_id])) {
                 $bindVars['metatags_keywords'] = zen_db_prepare_input($pParamHash['metatags_keywords'][$language_id]);
             }
             if (!empty($pParamHash['metatags_description'][$language_id])) {
                 $bindVars['metatags_description'] = zen_db_prepare_input($pParamHash['metatags_description'][$language_id]);
             }
             $this->mDb->query("DELETE FROM " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " WHERE `products_id`=?", array($this->mProductsId));
             if (!empty($bindVars)) {
                 if (!empty($bindVars)) {
                     $bindVars['products_id'] = $this->mProductsId;
                     $bindVars['language_id'] = $language_id;
                     $this->mDb->associateInsert(TABLE_META_TAGS_PRODUCTS_DESCRIPTION, $bindVars);
                 }
             }
             $this->storeProductImage($pParamHash);
         }
     }
     $this->CompleteTrans();
     $this->load();
     return count($this->mErrors) == 0;
 }