public function activateDefaultPlan(User_Model_User $user) { $packagesTable = Engine_Api::_()->getDbtable('packages', 'payment'); $gatewaysTable = Engine_Api::_()->getDbtable('gateways', 'payment'); // Have any gateways or packages been added yet? if ($gatewaysTable->getEnabledGatewayCount() <= 0 || $packagesTable->getEnabledNonFreePackageCount() <= 0) { return false; } // See if they've had a plan before $hasSubscription = (bool) $this->select()->from($this, new Zend_Db_Expr('TRUE'))->where('user_id = ?', $user->getIdentity())->limit(1)->query()->fetchColumn(); if ($hasSubscription) { return false; } // Get the default package $package = $packagesTable->fetchRow(array('`default` = ?' => true, 'enabled = ?' => true, 'price <= ?' => 0)); if (!$package) { return false; } // Create the default subscription $subscription = $this->createRow(); $subscription->setFromArray(array('package_id' => $package->package_id, 'user_id' => $user->getIdentity(), 'status' => 'initial', 'active' => false, 'creation_date' => new Zend_Db_Expr('NOW()'))); $subscription->save(); // Set active $subscription->setActive(true); $subscription->onPaymentSuccess(); return $subscription; }
public function createuserAction() { $t = Doctrine::getTable('User_Model_User'); try { $c = $t->count(); if ($c > 0) { $this->_helper->redirector->gotoSimple('success', 'install', 'install'); } else { $this->view->form = new Install_Form_InstallUser(); if ($this->request->isPost()) { if ($this->view->form->isValid($_POST)) { $values = $this->view->form->getValues(); $user = new User_Model_User(); $user->name = $values['username']; $user->setPassword($values['password1']); $user->email = $values['email']; $user->save(); $ur = new User_Model_Role(); $ur->User_Model_User = $user; $ur->role_name = 'admin_admin'; $ur->save(); $this->_helper->redirector->gotoSimple('success', 'install', 'install'); } } } } catch (Doctrine_Exception $e) { $this->_helper->redirector->gotoSimple('index', 'install', 'install'); } }
public function isAllowedToView(User_Model_User $user) { // Check level $selectedLevels = Zend_Json::decode($this->level); if (!empty($selectedLevels) && is_array($selectedLevels)) { // Get user level $levelIdentity = null; if (!$user->getIdentity()) { $levelIdentity = Engine_Api::_()->getDbtable('levels', 'authorization')->getPublicLevel()->level_id; } else { $levelIdentity = $user->level_id; } if (in_array($levelIdentity, $selectedLevels)) { return true; } } // Check network if ($user->getIdentity()) { $selectedNetworks = Zend_Json::decode($this->network); if (!empty($selectedNetworks) && is_array($selectedNetworks)) { $userNetworks = Engine_Api::_()->getDbtable('membership', 'network')->getMembershipsOfIds($user, null); if (count(array_intersect($userNetworks, $selectedNetworks)) > 0) { return true; } } } return false; }
public function check(User_Model_User $user) { // No CLI if ('cli' === PHP_SAPI) { return; } // Prepare $id = (int) $user->getIdentity(); // Get ip address $db = $this->getAdapter(); $ipObj = new Engine_IP(); $ipExpr = new Zend_Db_Expr($db->quoteInto('UNHEX(?)', bin2hex($ipObj->toBinary()))); // Run update first $count = $this->update(array('active' => date('Y-m-d H:i:s')), array('user_id = ?' => $id, 'ip = ?' => $ipExpr, 'active > ?' => new Zend_Db_Expr('DATE_SUB(NOW(),INTERVAL 20 MINUTE)'))); // Run insert if update doesn't do anything if ($count < 1) { if ($this->getAdapter() instanceof Zend_Db_Adapter_Mysqli || $this->getAdapter() instanceof Engine_Db_Adapter_Mysql || $this->getAdapter() instanceof Zend_Db_Adapter_Pdo_Mysql) { $sql = 'INSERT IGNORE INTO `' . $this->info('name') . '` (`user_id`, `ip`, `active`) VALUES (?, UNHEX(?), ?)'; $sql = $this->getAdapter()->quoteInto($sql, $id, null, 1); $sql = $this->getAdapter()->quoteInto($sql, bin2hex($ipObj->toBinary()), null, 1); $sql = $this->getAdapter()->quoteInto($sql, date('Y-m-d H:i:s'), null, 1); $this->getAdapter()->query($sql); } else { $this->insert(array('user_id' => $id, 'ip' => $ipExpr, 'active' => date('Y-m-d H:i:s'))); } } return $this; }
public function commonviewAction() { // $this->view->title = "View user"; // //Acl // $access = new App_Model_Access(); // $checkaccess = $access->accessRights('User',$this->view->globalvalue[0]['name'],'commonviewAction'); // if (($checkaccess != NULL)) { // calling search form // $SectForm = new Sectors_Form_Search(); // $this->view->form = $SectForm; //getting the id $id = $this->_getParam('id'); $this->view->id = $id; //getting the model $userdetails = new User_Model_User(); $user_details1 = $userdetails->getUser($id); $module = $userdetails->getmodule('User'); foreach ($module as $module_id) { } //displaying the submodule details $this->view->mod_id = $module_id['parent']; $this->view->sub_id = $module_id['module_id']; $this->view->userdetails = $user_details1; $this->view->address = $this->view->adm->getModule("ourbank_address", $id, "User"); $this->view->contact = $this->view->adm->getModule("ourbank_contact", $id, "User"); // } else { // $this->_redirect('index/error'); // } }
public function getSpecialAlbum(User_Model_User $user, $type) { if (!in_array($type, array('wall', 'profile', 'message'))) { throw new Album_Model_Exception('Unknown special album type'); } $select = $this->select()->where('owner_type = ?', $user->getType())->where('owner_id = ?', $user->getIdentity())->where('type = ?', $type)->order('album_id ASC')->limit(1); $album = $this->fetchRow($select); // Create wall photos album if it doesn't exist yet if (null === $album) { $translate = Zend_Registry::get('Zend_Translate'); $album = $this->createRow(); $album->owner_type = 'user'; $album->owner_id = $user->getIdentity(); $album->title = $translate->_(ucfirst($type) . ' Photos'); $album->type = $type; if ($type == 'message') { $album->search = 0; } else { $album->search = 1; } $album->save(); // Authorizations if ($type != 'message') { $auth = Engine_Api::_()->authorization()->context; $auth->setAllowed($album, 'everyone', 'view', true); $auth->setAllowed($album, 'everyone', 'comment', true); } } return $album; }
public function closeConversation(User_Model_User $user, $other_user_id) { $other_user_id = (int) $other_user_id; // Close sender $this->update(array('sender_deleted' => 1), array('sender_id = ?' => $user->getIdentity(), 'recipient_id = ?' => $other_user_id)); // Close recipient $this->update(array('recipient_deleted' => 1), array('recipient_id = ?' => $user->getIdentity(), 'sender_id = ?' => $other_user_id)); }
/** * * retrieve user id from session and fetch user from model * * @param Doctrine\ORM\EntityManager $em * @param Zend_Log $logger */ public static function getUser($em, $logger) { include_once 'user/models/User.php'; $userModel = new User_Model_User($em, $logger); $userobj = Zend_Auth::getInstance()->getIdentity(); $user = $userModel->fetch($userobj->user_id); return $user; }
public function getOutboxCountSelect(User_Model_User $user) { $rName = Engine_Api::_()->getDbtable('recipients', 'messages')->info('name'); $cName = $this->info('name'); $select = new Zend_Db_Select($this->getAdapter()); $select->from($cName, new Zend_Db_Expr('COUNT(1) AS zend_paginator_row_count'))->joinRight($rName, "`{$rName}`.`conversation_id` = `{$cName}`.`conversation_id`", null)->where("`{$rName}`.`user_id` = ?", $user->getIdentity())->where("`{$rName}`.`outbox_deleted` = ?", 0); return $select; }
/** * Check if a notification is enabled * * @param User_Model_User $user User to check for * @param string $type Notification type * @return bool Enabled */ public function checkEnabledNotification(User_Model_User $user, $type) { $select = $this->select()->where('user_id = ?', $user->getIdentity())->where('type = ?', $type)->limit(1); $row = $this->fetchRow($select); if (null === $row) { return true; } return (bool) $row->email; }
/** * Check if a action is enabled * * @param User_Model_User $user User to check for * @param string $type Action type * @return bool Enabled */ public function checkEnabledAction(User_Model_User $user, $type) { $canDisable = Engine_Api::_()->getApi('settings', 'core')->getSetting('activity.publish', true); if (!$canDisable) { return true; } $val = $this->select()->from($this->info('name'), 'publish')->where('user_id = ?', $user->getIdentity())->where('type = ?', $type)->limit(1)->query()->fetchColumn(0); return false === $val || $val; }
public function getRequest(User_Model_User $user) { $select = $this->select(); if ($user) { $select->where("user_id = ? ", $user->getIdentity()); $select->where("user_approved = ? ", '0'); } return $this->fetchAll($select); }
/** * Fetch all the users * * @return \User_Model_User */ public function fetchAll() { $resultSet = $this->getDbTable()->fetchAll(); $users = array(); foreach ($resultSet as $row) { $user = new User_Model_User(); $user->setId($row->id)->setEmail($row->email)->setFirstname($row->firstname)->setLastname($row->lastname)->setAddress($row->address)->setPhone($row->phone); $users[] = $user; } return $users; }
public function setSetting(User_Model_User $user, $key, $value) { if (null === $value) { $this->delete(array('user_id = ?' => $user->getIdentity(), 'name = ?' => $key)); } else { if (null === ($prev = $this->getSetting($user, $key)) || false === $prev) { $this->insert(array('user_id' => $user->getIdentity(), 'name' => $key, 'value' => $value)); } else { $this->update(array('value' => $value), array('user_id = ?' => $user->getIdentity(), 'name = ?' => $key)); } } return $this; }
public function IsGroupAllowed($module, $controller, $action, $user_id = null) { $this->_dbTableUser = new Acl_Model_DbTable_Users(); if (is_null($user_id)) { $user_id = Zend_Auth::getInstance()->getIdentity()->id; } $user = $this->_dbTableUser->fetchUser($user_id); $parsed_request = $module . ':' . $controller . ':' . $action; $this->_acl = Zend_Controller_Front::getInstance()->getPlugin('Acl_Plugin_Control')->getAcl(); if ($this->_acl->has($parsed_request)) { return $this->_acl->isAllowed($user->role_name, $parsed_request); } }
public function getSaveFeeds(User_Model_User $user, $types, $params = array()) { $limit = (!empty($params['limit']) ? $params['limit'] : 15) * 2; $max_id = $params['max_id']; $select = $this->select()->where('user_id = ?', $user->getIdentity())->where('action_type IN(?)', (array) $types)->limit($limit); if (null !== $max_id) { $select->where('action_id <= ?', $max_id); } $data = $select->query()->fetchAll(); $settings = array(); foreach ($data as $row) { $settings[] = $row['action_id']; } return $settings; }
public function check(User_Model_User $user, $rooms = array()) { if (!is_array($rooms)) { return; } foreach ($rooms as $index => $room_id) { if (!is_numeric($room_id)) { unset($rooms[$index]); } } if (empty($rooms)) { return; } $this->update(array('date' => date('Y-m-d H:i:s')), array('user_id = ?' => $user->getIdentity(), 'room_id IN(?)' => $rooms)); }
public function addAction() { $this->view->pageTitle = $this->translate('user_add_headline'); $this->view->form = new User_Form_EditUser(array(), true); $req = $this->getRequest(); if ($req->isPost()) { // there are profile updates if ($this->view->form->isValid($_POST)) { $values = $this->view->form->getValues(); $u = new User_Model_User(); $u->updateProfile($values); $this->session->message = $this->translate('user_admin_add_success'); $this->_helper->redirector->gotoSimple('index', 'admin', 'user'); } else { $this->view->message = $this->translate('user_admin_add_failed'); } } }
public function registerAction() { $formData = $this->getRequest()->getPost(); $form = new User_Form_User_RegisterForm(); $modelWep = new Model_Wep(); if ($formData) { if ($form->isValid($formData)) { $userModel = new User_Model_User(); $accountId = $userModel->registerUser($formData); $this->_helper->FlashMessenger->addMessage(array('message' => 'Thank you for registering.' . 'You will receive an email shortly.')); $this->_redirect('/'); } else { $this->_helper->FlashMessenger->addMessage(array('error' => 'Oops! something went wrong.' . ' Please check the fields marked in red to proceed.')); } } $this->view->form = $form; $this->view->placeholder('title')->set('Register user'); }
public function getKey(User_Model_User $user, $type = null, $expires = 0) { $select = $this->select()->where('user_id = ?', $user->getIdentity()); if (null !== $type) { $select->where('type = ?', $type); } if (!$expires) { $select->where('expires = ?', 0); } else { $select->where('expires > ?', time()); } $row = $this->fetchRow($select); if (null === $row) { return $this->createKey($user, $type, $expires); } else { return $row; } }
public function getSpecialAlbum(User_Model_User $user, $type) { if (!in_array($type, array('wall', 'profile', 'message'))) { throw new Advalbum_Model_Exception('Unknown special album type'); } $select = $this->select()->where('owner_type = ?', $user->getType())->where('owner_id = ?', $user->getIdentity())->where('type = ?', $type)->order('album_id ASC')->limit(1); $album = $this->fetchRow($select); // Create wall photos album if it doesn't exist yet if (null === $album) { $translate = Zend_Registry::get('Zend_Translate'); $album = $this->createRow(); $album->owner_type = 'user'; $album->owner_id = $user->getIdentity(); $album->title = $translate->_(ucfirst($type) . ' Photos'); $album->type = $type; $album->save(); } return $album; }
public function check(User_Model_User $user) { // Prepare $id = (int) $user->getIdentity(); $ip = ip2long($_SERVER['REMOTE_ADDR']); // Run update first $count = $this->update(array('active' => date('Y-m-d H:i:s')), array('user_id = ?' => $id, 'ip = ?' => $ip)); // Run insert if update doesn't do anything if ($count < 1) { if ($this->getAdapter() instanceof Zend_Db_Adapter_Mysqli || $this->getAdapter() instanceof Engine_Db_Adapter_Mysql || $this->getAdapter() instanceof Zend_Db_Adapter_Pdo_Mysql) { $sql = 'INSERT IGNORE INTO `' . $this->info('name') . '` (`user_id`, `ip`, `active`) VALUES (?, ?, ?)'; $sql = $this->getAdapter()->quoteInto($sql, $id, null, 1); $sql = $this->getAdapter()->quoteInto($sql, $ip, null, 1); $sql = $this->getAdapter()->quoteInto($sql, date('Y-m-d H:i:s'), null, 1); $this->getAdapter()->query($sql); } else { $this->insert(array('user_id' => $id, 'ip' => $ip, 'active' => date('Y-m-d H:i:s'))); } } return $this; }
public function testDatabase() { // first migrate database if needed if (Install_Api_Migration::getInstance()->getCurrentVersion() < Install_Api_Migration::getInstance()->getLatestVersion()) { Install_Api_Migration::getInstance()->migrate(); } $api = new Devtools_Api_DoctrineTool(); // truncate all tables or import data if there is some $api->importFixtures(APPLICATION_PATH . '/resource/fixtures'); // create an admin user for unit testing $user = new User_Model_User(); $user->name = 'PHPUnit'; $user->password = '******'; $user->email = '*****@*****.**'; $user->description = 'PHPUnit Testuser'; $user->activated = 'yes'; $user->active = 'no'; $user->show_team = 'no'; $user->save(); $role = new User_Model_Role(); $role->link('User_Model_User', array($user->id)); $role->role_name = 'admin_admin'; $role->save(); }
public function getBenefitStatus(User_Model_User $user = null) { // Get benefit setting $benefitSetting = Engine_Api::_()->getApi('settings', 'core')->getSetting('payment.benefit'); if (!in_array($benefitSetting, array('all', 'some', 'none'))) { $benefitSetting = 'all'; } switch ($benefitSetting) { default: case 'all': return true; break; case 'some': if (!$user) { return false; } return (bool) $this->select()->from($this, new Zend_Db_Expr('TRUE'))->where('user_id = ?', $user->getIdentity())->where('type = ?', 'payment')->where('status = ?', 'okay')->limit(1); break; case 'none': return false; break; } return false; }
public function indexAction() { $this->getView() ->setValues(array( 'title' => 'User' )) ->addCss('/js/ext-4.0.2a/resources/css/ext-all.css') ->addJs('/js/ext-4.0.2a/ext-all.js') ->addJs('/js/redokes/redokes.js'); if (User_Model_User::isLoggedIn()) { echo 'is logged in'; } else { $this->setView('login'); echo 'is not logged in'; } }
public function indexAction() { $envConf = Zend_Registry::get('environmentSettings'); $req = $this->getRequest(); $id = $req->getParam('id'); $title = $req->getParam('title'); $this->view->news = false; $this->view->paginator = false; $this->view->writeForm = new News_Form_Comment('#'); if ($id) { $this->view->news = News_Model_News::getNewsById($id); } else { if ($title) { $this->view->news = News_Model_News::getNewsBySlug(urldecode($title)); } } if ($this->view->news) { $paginator = $this->view->news->getCommentPaginator(false, true); $page = $req->getParam('page'); $paginator->setItemCountPerPage($this->conf->news->comments->numpage); $paginator->setCurrentPageNumber($page); $this->view->paginator = $paginator; } if ($req->isPost() && $this->view->news) { if ($this->view->writeForm->isValid($_POST)) { $values = $this->view->writeForm->getValues(); $nc = new News_Model_Comment(); $nc->ip = getenv('REMOTE_ADDR'); $nc->email = User_Model_User::isLoggedIn() ? Zend_Auth::getInstance()->getIdentity()->email : $values['email']; $nc->news_id = $this->view->news->id; $nc->visible = 'yes'; // there is no moderation yet $nc->author = User_Model_User::isLoggedIn() ? Zend_Auth::getInstance()->getIdentity()->name : $values['author']; $nc->url = $values['url']; $nc->comment = $values['comment']; $nc->checkSpam(); $nc->save(); $this->view->writeForm = new News_Form_Comment('#'); // clear form because comment is submitted } } }
public function removeAllUserFriendship(User_Model_User $user) { // first get all cases where user_id == $user->getIdentity $select = $this->getTable()->select()->where('user_id = ?', $user->getIdentity()); $friendships = $this->getTable()->fetchAll($select); foreach ($friendships as $friendship) { // if active == 1 get the user corresponding to resource_id and take away the member_count by 1 if ($friendship->active) { $friend = Engine_Api::_()->getItem('user', $friendship->resource_id); if ($friend && !empty($friend->member_count)) { $friend->member_count--; $friend->save(); } } $friendship->delete(); } // get all cases where resource_id == $user->getIdentity // remove all $this->getTable()->delete(array('resource_id = ?' => $user->getIdentity())); }
public function loginAction() { $settings = Zend_Registry::get('environmentSettings'); $layoutVersion = $settings->page->layout; # we don't need the admin menu $layout = Zend_Layout::getMvcInstance(); $layout->setLayout('frontend'); $layout->setLayoutPath(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'layouts' . DIRECTORY_SEPARATOR . $layoutVersion); # actually do the login stuff $form = new Admin_Form_Login(); $req = $this->getRequest(); $this->view->form = $form; if ($req->isPost()) { if ($form->isValid($_POST)) { $values = $form->getValues(); if (User_Model_User::login($values['username'], $values['password'])->isValid()) { return $this->_helper->redirector('index', 'index', 'admin'); } } } }
protected function _finishPayment($state = 'active') { $viewer = Engine_Api::_()->user()->getViewer(); $user = $this->_user; // No user? if (!$this->_user) { return $this->_helper->redirector->gotoRoute(array(), 'default', true); } // Log the user in, if they aren't already if (($state == 'active' || $state == 'free') && $this->_user && !$this->_user->isSelf($viewer) && !$viewer->getIdentity()) { Zend_Auth::getInstance()->getStorage()->write($this->_user->getIdentity()); Engine_Api::_()->user()->setViewer(); $viewer = $this->_user; } // Handle email verification or pending approval if ($viewer->getIdentity() && !$viewer->enabled) { Engine_Api::_()->user()->setViewer(null); Engine_Api::_()->user()->getAuth()->getStorage()->clear(); $confirmSession = new Zend_Session_Namespace('Signup_Confirm'); $confirmSession->approved = $viewer->approved; $confirmSession->verified = $viewer->verified; $confirmSession->enabled = $viewer->enabled; return $this->_helper->_redirector->gotoRoute(array('action' => 'confirm'), 'user_signup', true); } // Clear session $errorMessage = $this->_session->errorMessage; $userIdentity = $this->_session->user_id; $this->_session->unsetAll(); $this->_session->user_id = $userIdentity; $this->_session->errorMessage = $errorMessage; // Redirect if ($state == 'free') { return $this->_helper->redirector->gotoRoute(array(), 'default', true); } else { return $this->_helper->redirector->gotoRoute(array('action' => 'finish', 'state' => $state)); } }
public function __construct($action, $options = null) { parent::__construct($options); $this->setName('postcomment')->setAction($action)->setMethod('post')->setAttrib('id', 'postcomment'); # author $authorValidatorDB = new FansubCMS_Validator_NoRecordExists('User_Model_User', 'name'); $authorValidatorDB->setMessages(array(FansubCMS_Validator_NoRecordExists::RECORD_EXISTS => 'news_comment_form_error_author_user_exists')); $author = $this->createElement('text', 'author'); $author->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('stringLength', true, array('min' => 3, 'max' => 32, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'news_comment_form_error_author_length', Zend_Validate_StringLength::TOO_SHORT => 'news_comment_form_error_author_length')))->addValidator($authorValidatorDB)->setRequired(true)->setLabel('news_comment_field_author'); # email $email = $this->createElement('text', 'email'); $email->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addFilter('StripTags')->addFilter('StringTrim')->addValidator('EmailAddress', false, array('allow' => Zend_Validate_Hostname::ALLOW_DNS, 'domain' => true, 'messages' => array(Zend_Validate_EmailAddress::DOT_ATOM => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_FORMAT => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_LOCAL_PART => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_MX_RECORD => 'default_form_error_email', Zend_Validate_EmailAddress::INVALID_SEGMENT => 'default_form_error_email', Zend_Validate_EmailAddress::LENGTH_EXCEEDED => 'default_form_error_email', Zend_Validate_EmailAddress::QUOTED_STRING => 'default_form_error_email')))->setRequired(true)->setLabel('news_comment_field_email'); # url $url = $this->createElement('text', 'url'); $url->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->setLabel('news_comment_field_website'); # comment $comment = $this->createElement('Textarea', 'comment'); $comment->setRequired(true)->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->setAttrib('rows', 15)->setAttrib('cols', 40)->setLabel('news_comment_field_text'); #captcha if (!User_Model_User::isLoggedIn()) { $imgUrl = substr($_SERVER['PHP_SELF'], 0, -9) . '/media/common/images/tmp'; // little hack to have the correct baseurl $imgUrl = str_replace('//', '/', $imgUrl); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => 'captcha', 'captcha' => array('captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'height' => 80, 'width' => 150, 'startImage' => null, 'font' => realpath(APPLICATION_PATH . '/data/ttf') . '/captcha.ttf', 'imgurl' => $imgUrl, 'imgDir' => HTTP_PATH . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'tmp'), 'errorMessages' => array('default_form_error_captcha_wrong'))); $captcha->setRequired(true); } # add elements to the form if (!User_Model_User::isLoggedIn()) { $this->addElement($author)->addElement($email); } $this->addElement($url)->addElement($comment); if (!User_Model_User::isLoggedIn()) { $this->addElement($captcha); } # commit button $this->addElement('submit', 'submit', array('label' => 'news_comment_field_submit', 'class' => 'button')); }