/** * 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 (!is_null($this->m_error)) { return false; } $user = $p_context->user; if ($user->defined) { $this->m_properties['user_name'] = $p_context->user->name; $this->m_properties['user_email'] = $p_context->user->email; } else { switch(SystemPref::Get('PLUGIN_BLOGCOMMENT_MODE')) { case 'name': if (!strlen($this->m_properties['user_name'])) { $this->m_error = new PEAR_Error('Name was empty.', ACTION_BLOGCOMMENT_ERR_NO_NAME); return false; } break; case 'email': if (!strlen($this->m_properties['user_name'])) { $this->m_error = new PEAR_Error('Name was empty.', ACTION_BLOGCOMMENT_ERR_NO_NAME); return false; } if (!CampMail::ValidateAddress($this->m_properties['user_email'])) { $this->m_error = new PEAR_Error('Email was empty or invalid.', ACTION_BLOGCOMMENT_ERR_NO_EMAIL); return false; } break; case 'registered': default: $this->m_error = new PEAR_Error('Only registered users can post comments.', ACTION_BLOGCOMMENT_ERR_NOT_REGISTERED); return false; break; } } $this->m_error = ACTION_OK; return true; }
public function sendQuestioneerInvitation() { $MetaInterview = new MetaInterview($this->getId()); $headers = array( 'From' => $this->getProperty('invitation_sender'), 'Subject' => $this->getProperty('invitation_subject') ); // invite questioneers foreach (self::getQuestioneersWantInvitation() as $Questioneer) { $MetaUser = new MetaUser($Questioneer->getUserId()); $parsed = $this->smarty_parse_inviation_template($MetaInterview, $MetaUser, 'questioneer'); $parsed = str_replace("\r\n", "\n", $parsed); #$parsed = str_replace("\n", "\r\n", $parsed); CampMail::MailMime($Questioneer->getEmail(), null, $parsed, $headers); } $this->setProperty('questioneer_invitation_sent', strftime('%Y-%m-%d %H:%M:%S')); }
/** * 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 (!is_null($this->m_error)) { return false; } $user = $p_context->user; if ($user->defined) { $this->m_properties['user_name'] = ''; $this->m_properties['user_email'] = ''; } else { switch(SystemPref::Get('PLUGIN_BLOGCOMMENT_MODE')) { case 'name': if (!strlen($this->m_properties['user_name'])) { $this->m_error = new PEAR_Error('Name was empty.', ACTION_BLOGCOMMENT_ERR_NO_NAME); return false; } break; case 'email': if (!strlen($this->m_properties['user_name'])) { $this->m_error = new PEAR_Error('Name was empty.', ACTION_BLOGCOMMENT_ERR_NO_NAME); return false; } if (!CampMail::ValidateAddress($this->m_properties['user_email'])) { $this->m_error = new PEAR_Error('Email was empty or invalid.', ACTION_BLOGCOMMENT_ERR_NO_EMAIL); return false; } break; case 'registered': default: $this->m_error = new PEAR_Error('Only registered users can post comments.', ACTION_BLOGCOMMENT_ERR_NOT_REGISTERED); return false; break; } } $BlogEntry = new BlogEntry($this->m_properties['blogentry_id']); if ($this->m_blogcomment->create($BlogEntry->getId(), is_object($p_context->user) && $p_context->user->identifier ? $p_context->user->identifier : 0, $this->m_properties['user_name'], $this->m_properties['user_email'], $this->m_properties['title'], $this->m_properties['content'], $this->m_properties['mood_id'])) { $this->m_error = ACTION_OK; return true; } return false; }