/** * Build the form and show the template * * @param array $dirty reference to unverified $_POST */ function formBuild(&$dirty) { // -------------------------------------------------------------------- // Form logic // -------------------------------------------------------------------- if (!empty($dirty)) { $this->tpl->assign($dirty); } else { suxValidate::disconnect(); } if (!suxValidate::is_registered_form()) { suxValidate::connect($this->tpl, true); // Reset connection // Register our validators suxValidate::register_validator('integrity', 'integrity:parent_id', 'hasIntegrity'); suxValidate::register_validator('title', 'title', 'notEmpty', false, false, 'trim'); suxValidate::register_validator('body', 'body', 'notEmpty', false, false, 'trim'); } // Additional variables $this->r->text['form_url'] = suxFunct::makeUrl('/blog/reply/' . $this->parent['id']); $this->r->text['back_url'] = suxFunct::getPreviousURL(); // Parent $this->tpl->assign('parent_id', $this->parent['id']); $this->tpl->assign('parent', "{$this->parent['title']} \n\n {$this->parent['body_plaintext']}"); $this->r->title .= " | {$this->r->gtext['blog']} | {$this->r->gtext['reply']}"; // Template $this->tpl->display('reply.tpl'); }
/** * Build the form and show the template * * @param array $dirty reference to unverified $_POST */ function formBuild(&$dirty) { if (!empty($dirty)) { $this->tpl->assign($dirty); } else { suxValidate::disconnect(); } if (!suxValidate::is_registered_form()) { suxValidate::connect($this->tpl, true); // Reset connection // Register our additional criterias suxValidate::register_criteria('isDuplicateOpenIDUrl', 'this->isDuplicateOpenIDUrl'); // Register our validators // register_validator($id, $field, $criteria, $empty = false, $halt = false, $transform = null, $form = 'default') suxValidate::register_validator('url', 'url', 'notEmpty', false, false, 'trim'); suxValidate::register_validator('url2', 'url', 'isURL'); suxValidate::register_validator('url3', 'url', 'isDuplicateOpenIDUrl'); } // Title $this->r->title .= " | {$this->r->gtext['openid_reg']}"; // Urls $this->r->text['form_url'] = suxFunct::makeUrl('/user/register/openid'); $this->r->text['back_url'] = suxFunct::getPreviousURL($this->prev_skip); // Template $this->tpl->display('register_openid.tpl'); }
/** * Constructor * * @param string $nickname nickname */ function __construct($nickname) { // Declare objects $this->r = new userRenderer($this->module); // Renderer parent::__construct(); // Let the parent do the rest // Declare properties $this->r->bool['analytics'] = true; // Turn on analytics $this->profile = $this->user->getByNickname($nickname, true); unset($this->profile['password']); // We don't need this if (!$this->profile) { suxFunct::redirect(suxFunct::getPreviousURL()); } // Redirect for invalid profiles }
/** * Constructor * */ function __construct() { // Declare objects $this->nb = new suxUserNaiveBayesian(); $this->r = new bayesRenderer($this->module); // Renderer suxValidate::register_object('this', $this); // Register self to validator parent::__construct(); // Let the parent do the rest // If feature is turned off, then redirect if ($GLOBALS['CONFIG']['FEATURE']['bayes'] == false) { suxFunct::redirect(suxFunct::getPreviousURL()); } // Redirect if not logged in if (empty($_SESSION['users_id'])) { suxFunct::redirect(suxFunct::makeUrl('/user/register')); } }
/** * The form was successfuly processed */ function formSuccess() { // Template $this->r->text['back_url'] = suxFunct::getPreviousURL(); $this->r->title .= " | {$this->r->gtext['success']}"; $this->tpl->display('success.tpl'); }
function formSuccess() { suxFunct::redirect(suxFunct::getPreviousURL('cropper')); }
/** * Build the form and show the template * * @param array $dirty reference to unverified $_POST */ function formBuild(&$dirty) { // -------------------------------------------------------------------- // Pre assign template variables, maybe overwritten by &$dirty // -------------------------------------------------------------------- $blog = array(); if ($this->id) { // Editing a blog post $tmp = $this->msg->getByID($this->id); $blog['id'] = $tmp['id']; $blog['title'] = $tmp['title']; $blog['image'] = $tmp['image']; $blog['body'] = htmlentities($tmp['body_html'], ENT_QUOTES, 'UTF-8'); // Textarea fix $blog['draft'] = $tmp['draft']; $blog['thread_pos'] = $tmp['thread_pos']; // Get publish date // regex must match '2008-06-18 16:53:29' or '2008-06-18T16:53:29-04:00' $matches = array(); $regex = '/^(\\d{4})-(0[0-9]|1[0,1,2])-([0,1,2][0-9]|3[0,1]).+(\\d{2}):(\\d{2}):(\\d{2})/'; preg_match($regex, $tmp['published_on'], $matches); $blog['Date_Year'] = @$matches[1]; // year $blog['Date_Month'] = @$matches[2]; // month $blog['Date_Day'] = @$matches[3]; // day $blog['Time_Hour'] = @$matches[4]; // hour $blog['Time_Minute'] = @$matches[5]; // minutes $blog['Time_Second'] = @$matches[6]; //seconds /* Tags */ $links = $this->link->getLinks('link__messages__tags', 'messages', $blog['id']); $blog['tags'] = ''; foreach ($links as $val) { $tmp = $this->tags->getByID($val); $blog['tags'] .= $tmp['tag'] . ', '; } $blog['tags'] = rtrim($blog['tags'], ', '); /* Naive Bayesian: 1) Get the `link__bayes_documents__messages` matching this messages_id 2) Foreach linking bayes_document_id 3) get the categories I can train (nb::isCategoryTrainer($cat_id, $users_id) 4) stuff them into {$category_id} for template, append doc_id to {$link} string */ $links = $this->link->getLinks('link__bayes_documents__messages', 'messages', $blog['id']); $blog['linked'] = ''; foreach ($links as $val) { $cat = $this->nb->getCategoriesByDocument($val); foreach ($cat as $key => $val2) { if ($this->nb->isCategoryTrainer($key, $_SESSION['users_id'])) { $blog['linked'] .= "{$val}, "; $blog['category_id'][] = $key; } } } $blog['linked'] = rtrim($blog['linked'], ', '); // Remove trailing comma // Don't allow spoofing unset($dirty['id']); } // Assign blog $this->tpl->assign($blog); // -------------------------------------------------------------------- // Form logic // -------------------------------------------------------------------- if (!empty($dirty)) { $this->tpl->assign($dirty); } else { suxValidate::disconnect(); } if (!suxValidate::is_registered_form()) { suxValidate::connect($this->tpl, true); // Reset connection // Register our validators if ($this->id) { suxValidate::register_validator('integrity', 'integrity:id', 'hasIntegrity'); } suxValidate::register_validator('title', 'title', 'notEmpty', false, false, 'trim'); suxValidate::register_validator('image', 'image:' . $this->extensions, 'isFileType', true); suxValidate::register_validator('image2', 'image:' . ini_get('upload_max_filesize'), 'isFileSize', true); suxValidate::register_validator('body', 'body', 'notEmpty', false, false, 'trim'); suxValidate::register_validator('date', 'Date:Date_Year:Date_Month:Date_Day', 'isDate', false, false, 'makeDate'); suxValidate::register_validator('time', 'Time_Hour', 'isInt'); suxValidate::register_validator('time2', 'Time_Minute', 'isInt'); suxValidate::register_validator('time3', 'Time_Second', 'isInt'); } // -------------------------------------------------------------------- // Template // -------------------------------------------------------------------- // Additional $this->r->text['upload_max_filesize'] = ini_get('upload_max_filesize'); $this->r->text['supported'] = $this->extensions; $this->r->text['form_url'] = suxFunct::makeUrl('/blog/edit/' . $this->id); $this->r->text['back_url'] = suxFunct::getPreviousURL(); if (!$this->tpl->getTemplateVars('Date_Year')) { // Today's Date $this->tpl->assign('Date_Year', date('Y')); $this->tpl->assign('Date_Month', date('m')); $this->tpl->assign('Date_Day', date('j')); } if (!$this->tpl->getTemplateVars('Time_Hour')) { // Current Time $this->tpl->assign('Time_Hour', date('H')); $this->tpl->assign('Time_Minute', date('i')); $this->tpl->assign('Time_Second', date('s')); } if ($this->id) { $this->r->title .= " | {$this->r->gtext['edit_2']}"; } else { $this->r->title .= " | {$this->r->gtext['new']}"; } // Template $this->tpl->display('edit.tpl'); }
/** * View photo */ function view($id) { // Get nickname if (isset($_SESSION['nickname'])) { $nn = $_SESSION['nickname']; } else { $nn = 'nobody'; } // "Cache Groups" using a vertical bar | $cache_id = "{$nn}|view|{$id}"; $this->tpl->caching = 1; if (!$this->tpl->isCached('view.tpl', $cache_id)) { $this->r->arr['photos'] = $this->photo->getPhotoByID($id); if ($this->r->arr['photos'] == false || !count($this->r->arr['photos'])) { suxFunct::redirect(suxFunct::getPreviousURL()); } else { $this->r->arr['photos']['image'] = suxPhoto::t2fImage($this->r->arr['photos']['image']); // Fullsize // Album info $this->r->arr['album'] = $this->photo->getAlbumByID($this->r->arr['photos']['photoalbums_id']); $tmp = $this->user->getByID($this->r->arr['album']['users_id']); $this->r->arr['album']['nickname'] = $tmp['nickname']; // Previous, next, and page number $prev_id = null; $next_id = null; $page = 1; $query = 'SELECT id FROM photos WHERE photoalbums_id = ? ORDER BY image '; // Same order as suxPhoto->getPhotos() $db = suxDB::get(); $st = $db->prepare($query); $st->execute(array($this->r->arr['photos']['photoalbums_id'])); $i = 0; while ($prev_next = $st->fetch(PDO::FETCH_ASSOC)) { ++$i; if ($prev_next['id'] == $id) { break; } if ($i >= $this->per_page) { $i = 0; ++$page; } $prev_id = $prev_next['id']; } $prev_next = $st->fetch(PDO::FETCH_ASSOC); $next_id = $prev_next['id']; $this->r->text['prev_id'] = $prev_id; $this->r->text['next_id'] = $next_id; $this->r->text['back_url'] = suxFunct::makeUrl('photos/album/' . $this->r->arr['photos']['photoalbums_id'], array('page' => $page)); $this->r->title .= " | {$this->r->gtext['photos']} | {$this->r->arr['album']['title']}"; } } $this->tpl->display('view.tpl', $cache_id); }
/** * The form was successfuly processed */ function formSuccess() { // clear all caches with "nickname" as the first cache_id group $this->tpl->clearCache(null, "{$_SESSION['nickname']}"); // Redirect suxFunct::redirect(suxFunct::getPreviousURL()); }
/** * Process the form * * @param array $clean reference to validated $_POST */ function formProcess(&$clean) { // Security check if ($clean['users_id'] != $_SESSION['users_id']) { // Check that the user is allowed to be here if (!$this->user->isRoot()) { suxFunct::redirect(suxFunct::getPreviousURL()); } } // Accounts if (isset($clean['detach'])) { foreach ($clean['detach'] as $url) { if (!$this->user->isRoot()) { $tmp = $this->user->getUserByOpenID($url); if ($tmp['users_id'] != $_SESSION['users_id']) { continue; } // Skip } $this->user->detachOpenID($url); } } // Trusted consumers if (isset($clean['detach2'])) { foreach ($clean['detach2'] as $id => $url) { if (!$this->user->isRoot()) { $tmp = $this->openid->checkTrusted($_SESSION['users_id'], $url); if (!$tmp) { continue; } // Skip } $this->openid->untrustUrl($id); } } }
/** * The form was successfuly processed */ function formSuccess() { // Redirect suxFunct::redirect(suxFunct::getPreviousURL()); }
/** * Build the form and show the template * * @param array $dirty reference to unverified $_POST */ function formBuild(&$dirty) { // -------------------------------------------------------------------- // Pre assign template variables, maybe overwritten by &$dirty // -------------------------------------------------------------------- $change_me = array(); ### change me if ($this->id) { ### get the item from the database, assign it to the $change_me array. // Don't allow spoofing unset($dirty['id']); } // Assign $this->tpl->assign($change_me); ### change me // -------------------------------------------------------------------- // Form logic // -------------------------------------------------------------------- if (!empty($dirty)) { $this->tpl->assign($dirty); } else { suxValidate::disconnect(); } if (!suxValidate::is_registered_form()) { suxValidate::connect($this->tpl, true); // Reset connection // Register our validators ### add validators here, examples: // if ($this->id) suxValidate::register_validator('integrity', 'integrity:id', 'hasIntegrity'); // suxValidate::register_validator('title', 'title', 'notEmpty', false, false, 'trim'); ### @see: ./includes/symbionts/SmartyAddons/docs/SmartyValidate/README } // -------------------------------------------------------------------- // Template // -------------------------------------------------------------------- $this->r->text['form_url'] = suxFunct::makeUrl('/path/to/form' . $this->id); ### change me $this->r->text['back_url'] = suxFunct::getPreviousURL(); ### do template stuff here // Template $this->tpl->display('example.tpl'); ### change me }
/** * The form was successfuly processed */ function formSuccess() { // TODO: Same message as suggest bookmark from bookmarks module suxFunct::redirect(suxFunct::getPreviousURL()); // Redirect }
/** * The form was successfuly processed */ function formSuccess() { // Edit mode? if ($this->mode == 'edit') { $this->r->bool['edit'] = true; $this->r->text['back_url'] = suxFunct::getPreviousURL(); } $this->r->title .= " | {$this->r->gtext['success']}"; // Template $this->tpl->display('success.tpl'); }
/** * The form was successfuly processed */ function formSuccess() { // Template $this->r->text['back_url'] = suxFunct::getPreviousURL(); $this->r->title .= " | {$this->r->gtext['success']}"; $this->r->bool['edit'] = true; // Generic message $this->tpl->display('success.tpl'); }
/** * The form was successfuly processed */ function formSuccess() { // Redirect suxFunct::redirect(suxFunct::getPreviousURL($this->prev_skip)); }