Esempio n. 1
0
<?php

//sc/user/account/change-password.php
include 'sc-app.inc';
include APP_WEB_DIR . '/inc/header.inc';
include APP_WEB_DIR . '/inc/role/user.inc';
use com\indigloo\Util;
use com\indigloo\Url;
use com\indigloo\ui\form\Sticky;
use com\indigloo\Constants;
use com\indigloo\ui\form\Message as FormMessage;
use com\indigloo\sc\auth\Login;
use com\indigloo\exception\UIException;
$gSessionLogin = Login::getLoginInSession();
$loginId = $gSessionLogin->id;
if (strcmp($gSessionLogin->provider, Login::MIK) != 0) {
    $message = "change password only works for 3mik logins!";
    throw new UIException(array($message));
}
$userDao = new \com\indigloo\sc\dao\User();
$userDBRow = $userDao->getonLoginId($loginId);
//tokens for use in next screen
$ftoken = Util::getMD5GUID();
$email = $userDBRow["email"];
$femail = Util::encrypt($email);
$gWeb = \com\indigloo\core\Web::getInstance();
$gWeb->store("change.password.email", $femail);
$gWeb->store("change.password.token", $ftoken);
$title = $userDBRow["email"];
$qUrl = base64_encode(Url::current());
$fUrl = Url::current();
Esempio n. 2
0
File: comment.php Progetto: rjha/sc
try {
    $fhandler = new Form\Handler('web-form-1', $_POST);
    $fhandler->addRule('comment', 'Comment', array('required' => 1));
    $fhandler->addRule('post_id', 'post id', array('required' => 1));
    $fhandler->addRule('owner_id', 'owner id', array('required' => 1));
    $fhandler->addRule('post_title', 'post title', array('required' => 1));
    $fvalues = $fhandler->getValues();
    // UI checks
    if ($fhandler->hasErrors()) {
        throw new UIException($fhandler->getErrors());
    }
    //trim comments to 512 chars
    $fvalues["comment"] = substr($fvalues["comment"], 0, 512);
    //use login is required for comments
    if (Login::hasSession()) {
        $gSessionLogin = \com\indigloo\sc\auth\Login::getLoginInSession();
        $commentDao = new com\indigloo\sc\dao\Comment();
        $commentDao->create($gSessionLogin->id, $gSessionLogin->name, $fvalues['owner_id'], $fvalues['post_id'], $fvalues['post_title'], $fvalues['comment']);
        // go back to comment form
        header("Location: " . $fUrl);
    } else {
        //create data object representing pending session action
        $actionObj = new \stdClass();
        $actionObj->endPoint = "/qa/form/comment.php";
        $params = new \stdClass();
        $params->ownerId = $fvalues['owner_id'];
        $params->postId = $fvalues['post_id'];
        $params->title = $fvalues['post_title'];
        $params->comment = $fvalues['comment'];
        $params->action = UIConstants::ADD_COMMENT;
        $actionObj->params = $params;