Beispiel #1
0
    /**
     * Returns the value of the given property; throws
     * InvalidPropertyHandlerException if the property didn't exist.
     *
     * @param string $p_property
     * @return mixed
     */
    public function __get($p_property)
    {
        $p_property = MetaAction::TranslateProperty($p_property);

        if ($p_property == 'defined') {
            return $this->defined();
        }
        if ($p_property == 'is_error') {
            return PEAR::isError($this->m_error);
        }
        if ($p_property == 'error_code') {
            return PEAR::isError($this->m_error) ? $this->m_error->getCode() : null;
        }
        if ($p_property == 'error_message') {
            return PEAR::isError($this->m_error) ? $this->m_error->getMessage() : null;
        }
        if ($p_property == 'ok') {
            return $this->getError() === ACTION_OK;
        }
        if ($p_property == 'name') {
            return $this->m_name;
        }

        if (!is_array($this->m_properties)
        || !array_key_exists($p_property, $this->m_properties)) {
            $this->trigger_invalid_property_error($p_property);
        }
        if (is_string($this->m_properties[$p_property])
        && method_exists($this, $this->m_properties[$p_property])) {
            $methodName = $this->m_properties[$p_property];
            return $this->$methodName();
        }
        return $this->m_properties[$p_property];
    } // fn __get
Beispiel #2
0
 /**
  * Class constructor
  */
 public final function __construct()
 {
     global $Campsite, $controller;
     if (!is_null($this->m_properties)) {
         return;
     }
     $this->login_action = (object) array('is_error' => false, 'error_message' => '');
     self::$m_nullMetaArticle = new MetaArticle();
     self::$m_nullMetaSection = new MetaSection();
     // LEGACY PLUGINS
     // register plugin objects and listobjects
     foreach (CampPlugin::GetPluginsInfo(true) as $info) {
         if (is_array($info['template_engine']['objecttypes'])) {
             foreach ($info['template_engine']['objecttypes'] as $objecttype) {
                 $this->registerObjectType($objecttype);
             }
         }
         if (is_array($info['template_engine']['listobjects'])) {
             foreach ($info['template_engine']['listobjects'] as $listobject) {
                 $this->registerListObject($listobject);
             }
         }
     }
     // Register new plugins system list objects
     $pluginsService = \Zend_Registry::get('container')->get('newscoop.plugins.service');
     $collectedData = $pluginsService->collectListObjects();
     $this->m_listObjects = array_merge($collectedData['listObjects'], $this->m_listObjects);
     CampContext::$m_objectTypes = array_merge($collectedData['objectTypes'], CampContext::$m_objectTypes);
     $this->m_properties['htmlencoding'] = false;
     $this->m_properties['subs_by_type'] = null;
     $this->m_readonlyProperties['version'] = $Campsite['VERSION'];
     $this->m_readonlyProperties['current_list'] = null;
     $this->m_readonlyProperties['lists'] = array();
     $this->m_readonlyProperties['prev_list_empty'] = null;
     $this->m_readonlyProperties['default_url'] = new MetaURL();
     $this->m_readonlyProperties['url'] = new MetaURL();
     if (!$this->m_readonlyProperties['default_url']->is_valid) {
         if (!$this->m_readonlyProperties['url']->language->defined) {
             $this->m_readonlyProperties['url']->language = $this->m_readonlyProperties['url']->publication->default_language;
             $this->m_readonlyProperties['default_url'] = $this->m_readonlyProperties['url'];
         }
     }
     $this->m_objects['user'] = $this->m_readonlyProperties['url']->user;
     $this->m_readonlyProperties['preview'] = $this->m_readonlyProperties['url']->preview;
     if (!$this->m_readonlyProperties['preview']) {
         if (!$this->m_readonlyProperties['url']->article->is_published) {
             $this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle;
             $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle;
         }
         if (!$this->m_readonlyProperties['url']->issue->is_published) {
             $this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle;
             $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle;
             $this->m_readonlyProperties['default_url']->section = self::$m_nullMetaSection;
             $this->m_readonlyProperties['url']->section = self::$m_nullMetaSection;
             $this->m_readonlyProperties['default_url']->issue = new MetaIssue();
             $this->m_readonlyProperties['url']->issue = new MetaIssue();
         }
     }
     $this->m_objects['publication'] = $this->m_readonlyProperties['url']->publication;
     $this->m_objects['language'] = $this->m_readonlyProperties['url']->language;
     $this->m_objects['issue'] = $this->m_readonlyProperties['url']->issue;
     $this->m_objects['section'] = $this->m_readonlyProperties['url']->section;
     $this->m_objects['article'] = $this->m_readonlyProperties['url']->article;
     $this->m_objects['template'] = $this->m_readonlyProperties['url']->template;
     if (is_numeric($this->m_readonlyProperties['url']->get_parameter('tpid'))) {
         $this->m_objects['topic'] = new MetaTopic($this->m_readonlyProperties['url']->get_parameter('tpid'));
     }
     $this->m_readonlyProperties['default_template'] = $this->m_objects['template'];
     $this->m_readonlyProperties['default_language'] = $this->m_objects['language'];
     $this->m_readonlyProperties['default_publication'] = $this->m_objects['publication'];
     $this->m_readonlyProperties['default_issue'] = $this->m_objects['issue'];
     $this->m_readonlyProperties['default_section'] = $this->m_objects['section'];
     $this->m_readonlyProperties['default_article'] = $this->m_objects['article'];
     $this->m_readonlyProperties['default_topic'] = $this->topic;
     if (!is_null($commentId = CampRequest::GetVar('acid'))) {
         $this->m_objects['comment'] = new MetaComment($commentId);
     }
     $this->m_readonlyProperties['request_action'] = MetaAction::CreateAction(CampRequest::GetInput(CampRequest::GetMethod()));
     $requestActionName = $this->m_readonlyProperties['request_action']->name;
     $runAction = true;
     if ($requestActionName == 'submit_comment' && $pluginsService->isInstalled('terwey/plugin-newscoop-comments')) {
         $runAction = false;
     }
     if ($requestActionName != 'default' && $runAction) {
         $this->m_readonlyProperties['request_action']->takeAction($this);
     }
     foreach (MetaAction::ReadAvailableActions() as $actionName => $actionAttributes) {
         $propertyName = $actionName . '_action';
         if ($requestActionName == $actionName) {
             $this->m_readonlyProperties[$propertyName] =& $this->m_readonlyProperties['request_action'];
         } else {
             $this->m_readonlyProperties[$propertyName] = MetaAction::DefaultAction();
         }
     }
     // Initialize the default comment attribute at the end, after the
     // submit comment action had run.
     $this->m_readonlyProperties['default_comment'] = $this->comment;
     // add browser info
     $this->m_readonlyProperties['browser'] = new Browser();
     // initialize plugins
     foreach (CampPlugin::GetPluginsInfo(true) as $info) {
         if (function_exists($info['template_engine']['init'])) {
             $plugin_init = $info['template_engine']['init'];
             $plugin_init($this);
         }
     }
     // initialize geo-map holders
     $this->m_properties['map_dynamic_constraints'] = null;
     $this->m_properties['map_dynamic_areas'] = null;
     $this->m_properties['map_dynamic_max_points'] = 0;
     $this->m_properties['map_dynamic_tot_points'] = 0;
     $this->m_properties['map_dynamic_points_raw'] = null;
     $this->m_properties['map_dynamic_points_objects'] = null;
     $this->m_properties['map_dynamic_meta_article_objects'] = null;
     $this->m_properties['map_dynamic_map_label'] = "";
     $this->m_properties['map_dynamic_id_counter'] = 0;
     $this->m_properties['map_common_header_set'] = false;
     $flashMessenger = new \Newscoop\Controller\Helper\FlashMessenger();
     $this->flash_messages = $flashMessenger->getMessages();
 }
Beispiel #3
0
 /**
  * Class constructor
  */
 public final function __construct()
 {
     global $Campsite, $controller;
     if (!is_null($this->m_properties)) {
         return;
     }
     $this->login_action = (object) array('is_error' => false, 'error_message' => '');
     self::$m_nullMetaArticle = new MetaArticle();
     self::$m_nullMetaSection = new MetaSection();
     // register plugin objects and listobjects
     foreach (CampPlugin::GetPluginsInfo(true) as $info) {
         if (is_array($info['template_engine']['objecttypes'])) {
             foreach ($info['template_engine']['objecttypes'] as $objecttype) {
                 $this->registerObjectType($objecttype);
             }
         }
         if (is_array($info['template_engine']['listobjects'])) {
             foreach ($info['template_engine']['listobjects'] as $listobject) {
                 $this->registerListObject($listobject);
             }
         }
     }
     $this->m_properties['htmlencoding'] = false;
     $this->m_properties['subs_by_type'] = null;
     $this->m_readonlyProperties['version'] = $Campsite['VERSION'];
     $this->m_readonlyProperties['current_list'] = null;
     $this->m_readonlyProperties['lists'] = array();
     $this->m_readonlyProperties['prev_list_empty'] = null;
     $this->m_readonlyProperties['default_url'] = new MetaURL();
     $this->m_readonlyProperties['url'] = new MetaURL();
     if (!$this->m_readonlyProperties['default_url']->is_valid) {
         header('HTTP/1.0 404 Not Found');
         if (!$this->m_readonlyProperties['url']->language->defined) {
             $this->m_readonlyProperties['url']->language = $this->m_readonlyProperties['url']->publication->default_language;
             $this->m_readonlyProperties['default_url'] = $this->m_readonlyProperties['url'];
         }
     }
     $this->m_objects['user'] = $this->m_readonlyProperties['url']->user;
     $this->m_readonlyProperties['preview'] = $this->m_readonlyProperties['url']->preview;
     if (!$this->m_readonlyProperties['preview']) {
         if (!$this->m_readonlyProperties['url']->article->is_published) {
             $this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle;
             $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle;
         }
         if (!$this->m_readonlyProperties['url']->issue->is_published) {
             $this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle;
             $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle;
             $this->m_readonlyProperties['default_url']->section = self::$m_nullMetaSection;
             $this->m_readonlyProperties['url']->section = self::$m_nullMetaSection;
             $this->m_readonlyProperties['default_url']->issue = new MetaIssue();
             $this->m_readonlyProperties['url']->issue = new MetaIssue();
         }
     }
     $this->m_objects['publication'] = $this->m_readonlyProperties['url']->publication;
     $this->m_objects['language'] = $this->m_readonlyProperties['url']->language;
     $this->m_objects['issue'] = $this->m_readonlyProperties['url']->issue;
     $this->m_objects['section'] = $this->m_readonlyProperties['url']->section;
     $this->m_objects['article'] = $this->m_readonlyProperties['url']->article;
     $this->m_objects['template'] = $this->m_readonlyProperties['url']->template;
     if (is_numeric($this->m_readonlyProperties['url']->get_parameter('tpid'))) {
         $this->m_objects['topic'] = new MetaTopic($this->m_readonlyProperties['url']->get_parameter('tpid'));
     }
     $this->m_readonlyProperties['default_template'] = $this->m_objects['template'];
     $this->m_readonlyProperties['default_language'] = $this->m_objects['language'];
     $this->m_readonlyProperties['default_publication'] = $this->m_objects['publication'];
     $this->m_readonlyProperties['default_issue'] = $this->m_objects['issue'];
     $this->m_readonlyProperties['default_section'] = $this->m_objects['section'];
     $this->m_readonlyProperties['default_article'] = $this->m_objects['article'];
     $this->m_readonlyProperties['default_topic'] = $this->topic;
     if (!is_null($commentId = CampRequest::GetVar('acid'))) {
         $this->m_objects['comment'] = new MetaComment($commentId);
     }
     $this->m_readonlyProperties['request_action'] = MetaAction::CreateAction(CampRequest::GetInput(CampRequest::GetMethod()));
     $requestActionName = $this->m_readonlyProperties['request_action']->name;
     if ($requestActionName != 'default') {
         $this->m_readonlyProperties['request_action']->takeAction($this);
     }
     foreach (MetaAction::ReadAvailableActions() as $actionName => $actionAttributes) {
         $propertyName = $actionName . '_action';
         if ($requestActionName == $actionName) {
             $this->m_readonlyProperties[$propertyName] =& $this->m_readonlyProperties['request_action'];
         } else {
             $this->m_readonlyProperties[$propertyName] = MetaAction::DefaultAction();
         }
     }
     // Initialize the default comment attribute at the end, after the
     // submit comment action had run.
     $this->m_readonlyProperties['default_comment'] = $this->comment;
     // add browser info
     $this->m_readonlyProperties['browser'] = new Browser();
     // initialize plugins
     foreach (CampPlugin::GetPluginsInfo(true) as $info) {
         if (function_exists($info['template_engine']['init'])) {
             $plugin_init = $info['template_engine']['init'];
             $plugin_init($this);
         }
     }
     // initialize geo-map holders
     $this->m_properties['map_dynamic_constraints'] = null;
     $this->m_properties['map_dynamic_areas'] = null;
     $this->m_properties['map_dynamic_max_points'] = 0;
     $this->m_properties['map_dynamic_tot_points'] = 0;
     $this->m_properties['map_dynamic_points_raw'] = null;
     $this->m_properties['map_dynamic_points_objects'] = null;
     $this->m_properties['map_dynamic_meta_article_objects'] = null;
     $this->m_properties['map_dynamic_map_label'] = "";
     $this->m_properties['map_dynamic_id_counter'] = 0;
     $this->m_properties['map_common_header_set'] = false;
     if (defined('APPLICATION_PATH')) {
         $options = $controller->getInvokeArg('bootstrap')->getOptions();
         $form = new \Application_Form_Contact();
         $form->setMethod('POST');
         $request = \Zend_Controller_Front::getInstance()->getRequest();
         if ($request->isPost() && $form->isValid($request->getPost())) {
             $email = new \Zend_Mail('utf-8');
             $email->setFrom($form->email->getValue(), $form->first_name->getValue() . ' ' . $form->last_name->getValue())->setSubject($form->subject->getValue())->setBodyText($form->message->getValue())->addTo($options['email']['contact'])->send();
             $controller->getHelper('flashMessenger')->addMessage("form_contact_done");
             $controller->getHelper('redirector')->gotoUrl($request->getPathInfo());
             exit;
         }
         $this->form_contact = $form;
         $this->flash_messages = $controller->getHelper('flashMessenger')->getMessages();
     }
 }
Beispiel #4
0
 public function uninstall()
 {
     $info = $this->getPluginInfo();
     if (function_exists($info['uninstall'])) {
         call_user_func($info['uninstall']);
     }
     self::ClearPluginsInfo();
     $this->delete();
     MetaAction::DeleteActionsFromCache();
     self::ClearPluginsInfo();
 }
 /**
  * Returns the value of the given property; throws
  * InvalidPropertyHandlerException if the property didn't exist.
  *
  * @param string $p_property
  * @return mixed
  */
 public function __get($p_property)
 {
     $p_property = MetaAction::TranslateProperty($p_property);
     if ($p_property == 'results_count') {
         if (!empty($this->m_totalCount)) {
             return $this->m_totalCount;
         }
         if ($this->m_properties['scope'] == 'index') {
             Article::SearchByKeyword($this->m_properties['search_keywords'], $this->m_properties['match_all'], $this->m_properties['constraints'], array(), 0, 0, $this->m_totalCount, true);
         } else {
             Article::SearchByField($this->m_properties['search_keywords'], $this->m_properties['scope'], $this->m_properties['match_all'], $this->m_properties['constraints'], array(), 0, 0, $this->m_totalCount, true);
         }
         return $this->m_totalCount;
     }
     return parent::__get($p_property);
 }
Beispiel #6
0
    /**
     * Class constructor
     */
    final public function __construct()
    {
        global $Campsite;

        if (!is_null($this->m_properties)) {
            return;
        }

        self::$m_nullMetaArticle = new MetaArticle();
        self::$m_nullMetaSection = new MetaSection();

        // register plugin objects and listobjects
        foreach (CampPlugin::GetPluginsInfo(true) as $info) {
        	if (is_array($info['template_engine']['objecttypes'])) {
        		foreach ($info['template_engine']['objecttypes'] as $objecttype) {
        			$this->registerObjectType($objecttype);
        		}
        	}

        	if (is_array($info['template_engine']['listobjects'])) {
        		foreach ($info['template_engine']['listobjects'] as $listobject) {
        			$this->registerListObject($listobject);
        		}
        	}
        }

        $this->m_properties['htmlencoding'] = false;
        $this->m_properties['subs_by_type'] = null;

        $this->m_readonlyProperties['version'] = $Campsite['VERSION'];

        $this->m_readonlyProperties['current_list'] = null;
        $this->m_readonlyProperties['lists'] = array();
        $this->m_readonlyProperties['prev_list_empty'] = null;

        $this->m_readonlyProperties['default_url'] = new MetaURL();
        $this->m_readonlyProperties['url'] = new MetaURL();
        if (!$this->m_readonlyProperties['default_url']->is_valid) {
        	header('HTTP/1.0 404 Not Found');
        	if (!$this->m_readonlyProperties['url']->language->defined) {
        		$this->m_readonlyProperties['url']->language = $this->m_readonlyProperties['url']->publication->default_language;
        		$this->m_readonlyProperties['default_url'] = $this->m_readonlyProperties['url'];
        	}
        }

        $this->m_objects['user'] = $this->m_readonlyProperties['url']->user;
        $this->m_readonlyProperties['preview'] = $this->m_readonlyProperties['url']->preview;

        if (!$this->m_readonlyProperties['preview']) {
        	if (!$this->m_readonlyProperties['url']->article->is_published) {
        		$this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle;
                $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle;
        	}
            if (!$this->m_readonlyProperties['url']->issue->is_published) {
                $this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle;
                $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle;
                $this->m_readonlyProperties['default_url']->section = self::$m_nullMetaSection;
                $this->m_readonlyProperties['url']->section = self::$m_nullMetaSection;
                $this->m_readonlyProperties['default_url']->issue = new MetaIssue();
                $this->m_readonlyProperties['url']->issue = new MetaIssue();
            }
        }

        $this->m_objects['publication'] = $this->m_readonlyProperties['url']->publication;
        $this->m_objects['language'] = $this->m_readonlyProperties['url']->language;
        $this->m_objects['issue'] = $this->m_readonlyProperties['url']->issue;
        $this->m_objects['section'] = $this->m_readonlyProperties['url']->section;
        $this->m_objects['article'] = $this->m_readonlyProperties['url']->article;
        $this->m_objects['template'] = $this->m_readonlyProperties['url']->template;
        if (is_numeric($this->m_readonlyProperties['url']->get_parameter('tpid'))) {
            $this->m_objects['topic'] = new MetaTopic($this->m_readonlyProperties['url']->get_parameter('tpid'));
        }

        $this->m_readonlyProperties['default_template'] = $this->m_objects['template'];
        $this->m_readonlyProperties['default_language'] = $this->m_objects['language'];
        $this->m_readonlyProperties['default_publication'] = $this->m_objects['publication'];
        $this->m_readonlyProperties['default_issue'] = $this->m_objects['issue'];
        $this->m_readonlyProperties['default_section'] = $this->m_objects['section'];
        $this->m_readonlyProperties['default_article'] = $this->m_objects['article'];
        $this->m_readonlyProperties['default_topic'] = $this->topic;

        if (!is_null($commentId = CampRequest::GetVar('acid'))) {
            $this->m_objects['comment'] = new MetaComment($commentId);
        }

        $this->m_readonlyProperties['request_action'] = MetaAction::CreateAction(CampRequest::GetInput(CampRequest::GetMethod()));
        $requestActionName = $this->m_readonlyProperties['request_action']->name;
        if ($requestActionName != 'default') {
        	$this->m_readonlyProperties['request_action']->takeAction($this);
        }

        foreach (MetaAction::ReadAvailableActions() as $actionName=>$actionAttributes) {
            $propertyName = $actionName . '_action';
            if ($requestActionName == $actionName) {
                $this->m_readonlyProperties[$propertyName] =& $this->m_readonlyProperties['request_action'];
            } else {
                $this->m_readonlyProperties[$propertyName] = MetaAction::DefaultAction();
            }
        }

        // Initialize the default comment attribute at the end, after the
        // submit comment action had run.
        $this->m_readonlyProperties['default_comment'] = $this->comment;

        // add browser info
        $this->m_readonlyProperties['browser'] = new Browser;

        // initialize plugins
        foreach (CampPlugin::GetPluginsInfo(true) as $info) {
            if (function_exists($info['template_engine']['init'])) {
                $plugin_init = $info['template_engine']['init'];
                $plugin_init($this);
            }
        }
    } // fn __construct
    /**
     * Performs the action; returns true on success, false on error.
     *
     * @param $p_context - the current context object
     * @return bool
     */
    public function takeAction(CampContext &$p_context)
    {
        $p_context->default_url->reset_parameter('f_'.$this->m_name);
        $p_context->url->reset_parameter('f_'.$this->m_name);

        if (PEAR::isError($this->m_error)) {
            return false;
        }

        $metaUser = $p_context->user;
        if (!$metaUser->defined) {
            $this->m_properties['type'] = 'add';
            if (!MetaAction::ValidateInput($this->m_properties, 'name', 1,
            $this->m_error, 'The user name was not filled in.', ACTION_EDIT_USER_ERR_NO_NAME)) {
                return false;
            }
            if (!MetaAction::ValidateInput($this->m_properties, 'uname', 1,
            $this->m_error, 'The user login name was not filled in.',
            ACTION_EDIT_USER_ERR_NO_USER_NAME)) {
                return false;
            }
            if (!MetaAction::ValidateInput($this->m_properties, 'password', 6,
            $this->m_error, 'The user password was not filled in or was too short.',
            ACTION_EDIT_USER_ERR_NO_PASSWORD)) {
                return false;
            }
            if (!MetaAction::ValidateInput($this->m_properties, 'passwordagain', 6,
            $this->m_error, 'The password confirmation was not filled in or was too short.',
            ACTION_EDIT_USER_ERR_NO_PASSWORD_CONFIRMATION)) {
                return false;
            }
            if (!MetaAction::ValidateInput($this->m_properties, 'email', 8,
            $this->m_error, 'The user email was not filled in or was invalid.',
            ACTION_EDIT_USER_ERR_NO_EMAIL)) {
                return false;
            }

            if (SystemPref::Get('PLUGIN_RECAPTCHA_SUBSCRIPTIONS_ENABLED') == 'Y') {
                $captcha = Captcha::factory('ReCAPTCHA');
                if (!$captcha->validate()) {
                    $this->m_error = new PEAR_Error('The code you entered is not the same as the one shown.',
                        ACTION_SUBMIT_COMMENT_ERR_INVALID_CAPTCHA_CODE);
                    return false;
                }
            }
        } else {
            $this->m_properties['type'] = 'edit';
            if (isset($this->m_properties['password'])) {
                if (!MetaAction::ValidateInput($this->m_properties, 'password', 6,
                $this->m_error, 'The user password was not filled in or was too short.',
                ACTION_EDIT_USER_ERR_NO_PASSWORD)) {
                    return false;
                }
                if (!MetaAction::ValidateInput($this->m_properties, 'passwordagain', 6,
                $this->m_error, 'The password confirmation was not filled in or was too short.',
                ACTION_EDIT_USER_ERR_NO_PASSWORD_CONFIRMATION)) {
                    return false;
                }
            }
        }

        if (isset($this->m_properties['password'])
        && $this->m_properties['password'] != $this->m_properties['passwordagain']) {
            $this->m_error = new PEAR_Error("The password and password confirmation do not match.",
            ACTION_EDIT_USER_ERR_PASSWORD_MISMATCH);
            return false;
        }

        if (!$metaUser->defined) {
            if (User::UserNameExists($this->m_properties['uname'])
            || Phorum_user::UserNameExists($this->m_properties['uname'])) {
                $this->m_error = new PEAR_Error("The login name already exists, please choose a different one.",
                ACTION_EDIT_USER_ERR_DUPLICATE_USER_NAME);
                return false;
            }
            if (User::EmailExists($this->m_properties['email'])) {
                $this->m_error = new PEAR_Error("Another user is registered with this e-mail address, please choose a different one.",
                ACTION_EDIT_USER_ERR_DUPLICATE_EMAIL);
                return false;
            }
            $user = new User();
            $phorumUser = new Phorum_user();
            if (!$user->create($this->m_data)
            || !$phorumUser->create($this->m_properties['uname'], $this->m_properties['password'], $this->m_properties['email'], $user->getUserId())) {
                $user->delete();
                $phorumUser->delete();
                $this->m_error = new PEAR_Error("There was an internal error creating the account (code 1).",
                ACTION_EDIT_USER_ERR_INTERNAL);
                return false;
            }
            setcookie("LoginUserId", $user->getUserId(), null, '/');
            $user->initLoginKey();
            setcookie("LoginUserKey", $user->getKeyId(), null, '/');
            $p_context->user = new MetaUser($user->getUserId());
        } else {
            $user = new User($metaUser->identifier);
            if (!$user->exists()) {
                $this->m_error = new PEAR_Error("There was an internal error updating the account (code 2).",
                ACTION_EDIT_USER_ERR_INTERNAL);
                return false;
            }
            $phorumUser = Phorum_user::GetByUserName($user->getUserName());
            if (is_null($phorumUser)) {
                $phorumUser = new Phorum_user();
                if (!$phorumUser->create($user->getUserName(), $user->getPassword(), $user->getEmail(), $user->getUserId(), true)) {
                    $this->m_error = new PEAR_Error("There was an internal error updating the account (code 3).",
                    ACTION_EDIT_USER_ERR_INTERNAL);
                    return false;
                }
            }
            foreach ($this->m_properties as $property=>$value) {
                if (!isset(MetaActionEdit_User::$m_fields[$property]['db_field'])) {
                    continue;
                }
                $dbProperty = MetaActionEdit_User::$m_fields[$property]['db_field'];
                if ($property != 'password' && $property != 'passwordagain') {
                    $user->setProperty($dbProperty, $value, false);
                    if ($property == 'email') {
                        $phorumUser->setProperty('email', $value, false);
                    }
                } elseif ($property == 'password') {
                    $user->setPassword($this->m_properties['password'], false);
                    $phorumUser->setPassword($this->m_properties['password'], false);
                }
            }
            if (!$user->commit() || !$phorumUser->commit()) {
                $this->m_error = new PEAR_Error("There was an internal error updating the account (code 4).",
                ACTION_EDIT_USER_ERR_INTERNAL);
                return false;
            }
        }

        foreach ($this->m_properties as $property=>$value) {
            $p_context->default_url->reset_parameter('f_user_'.$property);
            $p_context->url->reset_parameter('f_user_'.$property);
        }

        $this->m_error = ACTION_OK;
        return true;
    }