Example #1
0
 /**
  * Execute the form.
  * The form has been validated and can be executed.
  * @param USER $obj
  * @access private
  */
 public function commit($obj)
 {
     $new_user = !$obj->exists();
     parent::commit($obj);
     $orig_email = $this->value_for('orig_email');
     $new_email = $this->value_for('email');
     if (!$new_user && $orig_email != $new_email) {
         /* mail has changed, update subscription information. If the mail is now empty,
            remove all subscription information. If the mail has changed, update the
            subscriber record. */
         $class_name = $this->app->final_class_name('SUBSCRIBER', 'webcore/obj/subscriber.php');
         /** @var SUBSCRIBER $subscriber */
         $subscriber = new $class_name($this->app);
         $subscriber->email = $orig_email;
         if (!$new_email) {
             $subscriber->purge();
         } else {
             if ($subscriber->exists()) {
                 $subscriber->email = $new_email;
                 $subscriber->store();
             }
         }
     }
     // If current user is anonymous, then log in as the newly created user
     if ($new_user && ($this->login->is_anonymous() || $this->login->ad_hoc_login)) {
         $this->app->log_in($obj, false);
     }
 }
 /**
  * Configure the history item's properties.
  * Prevents history items for invisible objects from queuing when the user hasn't expressed a preference.
  * 
  * @param OBJECT_IN_FOLDER $obj The object to be stored.
  * @param HISTORY_ITEM $history_item
  * @access private
  */
 protected function _adjust_history_item($obj, $history_item)
 {
     parent::_adjust_history_item($obj, $history_item);
     $pub_state = $this->value_for('publication_state');
     if ($pub_state == History_item_default) {
         if ($obj->visible()) {
             $history_item->publication_state = History_item_queued;
         } else {
             $history_item->publication_state = History_item_silent;
         }
     }
 }