Inheritance: extends Ordrin
 function __construct()
 {
     $count = getInput("count");
     $email = getInput("email");
     $password = getInput("password");
     $x = 0;
     while ($x < $count) {
         $first_name = $this->names[mt_rand(0, sizeof($this->names) - 1)];
         $last_name = $this->surnames[mt_rand(0, sizeof($this->surnames) - 1)];
         $user = new User();
         $user->password = md5($password);
         $user->random = true;
         $user->verified = "true";
         $user->profile_type = "default";
         $user->access_id = "system";
         $user->first_name = $first_name;
         $user->last_name = $last_name;
         $user->email = "tester" . $x . "@" . $email;
         $user->full_name = $first_name . " " . $last_name;
         $user->save();
         $x++;
     }
     new SystemMessage("Random users have been generated");
     forward();
 }
Example #2
1
 public function setUser(User $user)
 {
     if ($this->user !== $user) {
         $this->user = $user;
         $user->setAddress($this);
     }
 }
 public static function updateUser()
 {
     // Process updating of user information
     $users = UsersDB::getUsersBy('userId', $_SESSION['arguments']);
     if (empty($users)) {
         HomeView::show();
         header('Location: /' . $_SESSION['base']);
     } elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
         $_SESSION['users'] = $users;
         UserView::showUpdate();
     } else {
         $parms = $users[0]->getParameters();
         $parms['userName'] = array_key_exists('userName', $_POST) ? $_POST['userName'] : "";
         $parms['password'] = array_key_exists('password', $_POST) ? $_POST['password'] : "";
         $newUser = new User($parms);
         $newUser->setUserId($users[0]->getUserId());
         $user = UsersDB::updateUser($newUser);
         if ($user->getErrorCount() != 0) {
             $_SESSION['users'] = array($newUser);
             return;
             UserView::showUpdate();
         } else {
             HomeView::show();
             header('Location: /' . $_SESSION['base']);
         }
     }
 }
Example #4
1
 public function view()
 {
     $dao = DAO::getDAO('UserDAO');
     if (isset($this->params[0]) && trim($this->params[0]) == 'remove') {
         // ex: requesting: /user-list/delete/2
         $id = trim(sanitizeString($this->params[1]));
         $dao->removeById($id);
     } else {
         if (isset($this->params[0]) && trim($this->params[0]) == 'add') {
             $randNum = mt_rand(0, 99999);
             $newUser = new User(array('firstName' => 'First', 'lastName' => 'LastName', 'username' => "test{$randNum}", 'email' => "test{$randNum}@example.com", 'createTime' => dbDateTime()));
             // #TODO: implement UserDao.create($newUser) instead.
             if ($dao->countAll() > 30) {
                 // Demo mode: clean up if too many users
                 $dao->execute("DELETE FROM user");
                 $dao->execute("vacuum");
             }
             $dao->insertInto("firstName, lastName, username, email, createTime", $newUser->getFields());
         }
     }
     $users = $dao->getAll();
     $v = $this->smarty;
     $v->assign('title', 'User List');
     $v->assign('inc_content', v('user_list.html'));
     $v->assign('users', $users);
     $v->assign('totalUsers', $dao->countAll());
     $this->display($v, v('index.html'));
 }
/**
 * Handle on_milestone_add_links event
 *
 * @param Milestone $milestone
 * @param User $user
 * @param array $links
 * @return null
 */
function tickets_handle_on_milestone_add_links($milestone, $user, &$links)
{
    if ($user->getProjectPermission('ticket', $milestone->getProject()) >= PROJECT_PERMISSION_CREATE) {
        $links[lang('Ticket')] = tickets_module_add_ticket_url($milestone->getProject(), array('milestone_id' => $milestone->getId()));
    }
    // if
}
Example #6
1
 public function getAllowedFileExtensions()
 {
     $u = new User();
     $extensions = array();
     if ($u->isSuperUser()) {
         $extensions = Loader::helper('concrete/file')->getAllowedFileExtensions();
         return $extensions;
     }
     $pae = $this->getPermissionAccessObject();
     if (!is_object($pae)) {
         return array();
     }
     $accessEntities = $u->getUserAccessEntityObjects();
     $accessEntities = $pae->validateAndFilterAccessEntities($accessEntities);
     $list = $this->getAccessListItems(FileSetPermissionKey::ACCESS_TYPE_ALL, $accessEntities);
     $list = PermissionDuration::filterByActive($list);
     foreach ($list as $l) {
         if ($l->getFileTypesAllowedPermission() == 'N') {
             $extensions = array();
         }
         if ($l->getFileTypesAllowedPermission() == 'C') {
             $extensions = array_unique(array_merge($extensions, $l->getFileTypesAllowedArray()));
         }
         if ($l->getFileTypesAllowedPermission() == 'A') {
             $extensions = Loader::helper('concrete/file')->getAllowedFileExtensions();
         }
     }
     return $extensions;
 }
 public function createParent()
 {
     $input = Input::all();
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'));
     }
     $input['dob'] = date('Y-m-d H:i:s', strtotime(Input::get('dob')));
     $input['collegeid'] = Session::get('user')->collegeid;
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     $removed = array('_token', 'password', 'cpassword');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Parent::saveFormData($input);
     return $input;
 }
Example #8
0
 public function action_create()
 {
     $this->template->title = __("Thêm mới tài khoản");
     $this->template->section_title = __("Thêm mới tài khoản");
     $data = array();
     if (Request::$method == "POST") {
         $user = new User();
         $post = $user->validate_create($_POST);
         if ($post->check()) {
             $post_values = $post->as_array();
             //print_r($post_values);
             $t = $user->register($post_values['email'], $post_values['password'], (bool) $post_values['active']);
             if ($t) {
                 //Request::instance()->redirect('admin/user/index');
                 Request::instance()->redirect('admin/user/role/' . $t->id);
             } else {
                 $post->error('email', 'user_not_save', array('Can\'t save new user!'));
             }
         } else {
             #Repopulate $_POST data
             $_POST = $post->as_array();
             //error
             $data['errors'] = $post->errors('admin/user/form');
             //print_r($post->errors());
         }
     }
     $this->template->content = View::factory('admin/user/create', $data);
 }
 /**
  * Привязываем счёт к счёту в банке
  *
  * @return void
  */
 function binding()
 {
     if ($this->_user->getId() == 0) {
         $errorMessage = 'Необходимо авторизироваться';
     }
     if (isset($_POST['account_id'])) {
         $account_id = (int) $_POST['account_id'];
         if ($account_id <= 0) {
             $errorMessage = 'Неверный идентификатор счёта';
         }
     } else {
         $errorMessage = 'Необходимо указать счёт';
     }
     if (!isset($errorMessage)) {
         $debetCard = new Account_DebetCard();
         if (!$debetCard->binding($account_id)) {
             $errorMessage = 'Ошибка при привязывании счёта';
         }
     }
     if (isset($errorMessage)) {
         $this->renderJsonError($errorMessage);
     } else {
         $this->renderJsonSuccess('Счёт успешно привязан');
     }
 }
    public function testFromArrayRecord()
    {
        $user = new User();
        $userArray = $user->toArray();

        # add a Phonenumber
        $userArray['Phonenumber'][0]['phonenumber'] = '555 321';
        
        # add an Email address
        $userArray['Email']['address'] = '*****@*****.**';
        
        # add group
        $userArray['Group'][0]['name'] = 'New Group'; # This is a n-m relationship
        # add a group which exists
        $userArray['Group'][1]['_identifier'] = $this->previous_group; # This is a n-m relationship where the group was made in prepareData
          
        $user->fromArray($userArray);
        
        $this->assertEqual($user->Phonenumber->count(), 1);
        $this->assertEqual($user->Phonenumber[0]->phonenumber, '555 321');
        $this->assertEqual($user->Group[0]->name, 'New Group');
        $this->assertEqual($user->Group[1]->name, 'Group One');
        
        try {
          $user->save();
        } catch (Exception $e ) {
          $this->fail("Failed saving with " . $e->getMessage());
        }
    }
Example #11
0
 public function rescan_locale()
 {
     if ($this->token->validate('rescan_locale')) {
         $u = new \User();
         if ($u->isSuperUser()) {
             \Core::make('cache/request')->disable();
             $section = Section::getByID($_REQUEST['locale']);
             $target = new MultilingualProcessorTarget($section);
             $processor = new Processor($target);
             if ($_POST['process']) {
                 foreach ($processor->receive() as $task) {
                     $processor->execute($task);
                 }
                 $obj = new \stdClass();
                 $obj->totalItems = $processor->getTotalTasks();
                 echo json_encode($obj);
                 exit;
             } else {
                 $processor->process();
             }
             $totalItems = $processor->getTotalTasks();
             \View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
             exit;
         }
     }
 }
 /**
  * Load all orders
  *
  * @param User $user
  * @throws Exception
  */
 public function load(User $user)
 {
     if ($user->getUserGroup() != User::ADMIN_USER_GROUP) {
         throw new Exception('Only administrators can get reports');
     }
     //...
 }
 public function register()
 {
     if (Auth::check()) {
         return "You are already logged in. Please wait for the dashboard.";
     } else {
         $input = Input::all();
         $validator = Validator::make($input, array('fname' => "min:4 | max:20 | required", 'email' => 'min:5 | max:100 | required | unique:users,email', 'pass' => 'min:5 | max:30 | required', 'passch' => 'same:pass', 'beta' => 'required | exists:betacodes,code'), array('fname.required' => 'Please enter your name.', 'email.required' => 'Please enter your email.', 'pass.required' => 'Please enter a password.', 'beta.required' => 'Please enter your beta access code.', 'fname.min' => 'Your name must be longer than four letters.', 'fname.max' => 'Your name must be shorter than 20 letters.', 'email.min' => 'Your email must be longer than five letters.', 'email.max' => 'Your email must be shorter than 100 letters.', 'email.unique' => 'That email is already in use. Please use the "Forgot" page for assistance.', 'pass.min' => 'Your password must be longer than five letters.', 'pass.max' => 'Your password must be shorter than 30 letters.', 'passch.same' => 'Your passwords did not match.', 'beta.exists' => 'You entered an invalid beta code.'));
         if ($validator->fails()) {
             $messages = $validator->messages();
             $errors = array();
             foreach ($messages->all() as $message) {
                 array_push($errors, $message);
             }
             return $errors;
         }
         $categories = array(Input::get("fname") . "'s Servers");
         $user = new User();
         $user->fname = Input::get("fname");
         $user->email = Input::get("email");
         $user->password = Hash::make(Input::get('pass'));
         $user->save();
         Auth::login($user);
         $category = new Category();
         $category->uid = Auth::user()->id;
         $category->name = Auth::user()->fname . "s Category";
         $category->order = 999;
         $category->save();
         return "success";
     }
 }
 protected function checkCanExecute(User $user)
 {
     if (!$user->matchEditToken($this->getRequest()->getVal('token'), $this->getRequest()->getInt('rcid'))) {
         throw new ErrorPageError('sessionfailure-title', 'sessionfailure');
     }
     return parent::checkCanExecute($user);
 }
Example #15
0
 /**
  * Daily social statistic collect
  * Add new access token to Queue
  *
  * @access public
  * @return void
  */
 public function run()
 {
     $types = array('twitter');
     $tokens = Access_token::inst()->where_in('type', $types)->get();
     $aac = $this->getAAC();
     $now = new \DateTime('UTC');
     foreach ($tokens as $_token) {
         $now->modify('1 minutes');
         $user = new User($_token->user_id);
         if (!$user->exists()) {
             continue;
         }
         $aac->setUser($user);
         if (!$aac->isGrantedPlan('social_activity')) {
             continue;
         }
         $args = $_token->to_array();
         foreach ($_token->social_group->get() as $profile) {
             $args['profile_id'] = $profile->id;
             //Twitter tasks
             $this->jobQueue->addJob('tasks/twitter_task/searchUsers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/updateFollowers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/randomRetweet', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/randomFavourite', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/sendWelcomeMessage', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/followNewFollowers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
             $this->jobQueue->addJob('tasks/twitter_task/unfollowUnsubscribedUsers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
         }
     }
 }
 function setUp()
 {
     global $db, $timedate, $current_user;
     $this->original_current_user = $current_user;
     $user = new User();
     $user->retrieve('1');
     $current_user = $user;
     if ($db->dbType != 'mysql') {
         $this->markTestSkipped('Skipping for non-mysql dbs');
     }
     $this->meeting = SugarTestMeetingUtilities::createMeeting();
     $date_start = $timedate->nowDb();
     $this->meeting->date_start = $date_start;
     $this->meeting->duration_hours = 2;
     $this->meeting->duration_minutes = 30;
     $this->meeting->save();
     $sql = "UPDATE meetings SET date_end = '{$date_start}' WHERE id = '{$this->meeting->id}'";
     $db->query($sql);
     $this->call = SugarTestCallUtilities::createCall();
     $date_start = $timedate->nowDb();
     $this->call->date_start = $date_start;
     $this->call->duration_hours = 2;
     $this->call->duration_minutes = 30;
     $this->call->save();
     $sql = "UPDATE calls SET date_end = '{$date_start}' WHERE id = '{$this->call->id}'";
     $db->query($sql);
 }
Example #17
0
 function getRespondentsByUser(User $user, $filter = 0)
 {
     global $db;
     $respondents = array();
     $test = ' and test = 0';
     // this can be the supervisor looking
     $currentUser = new User($_SESSION['URID']);
     if ($currentUser->isTestMode()) {
         $test = ' and test = 1';
     }
     if ($currentUser->getRegionFilter() > 0 && $currentUser->getPuid() > 0) {
         //only certain region
         $test = ' and puid = ' . $currentUser->getPuid();
     }
     $result = $db->selectQuery('select *, ' . $this->getDeIdentified() . ' from ' . Config::dbSurvey() . '_respondents where urid = ' . prepareDatabaseString($user->getUrid()) . $test);
     while ($row = $db->getRow($result)) {
         $respondents[] = new Respondent($row);
     }
     if ($currentUser->getTestMode() && sizeof($respondents) == 0 && $currentUser->getRegionFilter() <= 0) {
         //psu filter!!
         if ($currentUser->getUserType() == USER_INTERVIEWER) {
             //only add if interviewer!
             if (dbConfig::defaultPanel() != PANEL_HOUSEHOLD) {
                 //only if not household sample
                 $respondents = $this->addTestRespondents($user);
             }
         }
     }
     if ($filter > 0) {
         //a filter!!
         $respondents = $this->filterRespondents($respondents, $filter);
     }
     return $respondents;
 }
 /**
  * Generates HTML for the uploads page for the passed user.
  *
  * @param User $user
  * @return string
  */
 public function getUserUploadsPageHtml(User $user)
 {
     $uploadCount = $this->getUserUploadCount($user->getName());
     $mobileContext = MobileContext::singleton();
     $html = '';
     $attrs = array();
     if ($uploadCount !== false) {
         $threshold = $this->getUploadCountThreshold();
         // FIXME: Use Html class?
         $html .= '<div class="content">';
         if ($mobileContext->userCanUpload()) {
             $html .= '<div class="ctaUploadPhoto"></div>';
         }
         if ($uploadCount > $threshold) {
             $msg = $this->msg('mobile-frontend-photo-upload-user-count-over-limit')->text();
         } else {
             $msg = $this->msg('mobile-frontend-photo-upload-user-count')->numParams($uploadCount)->parse();
             if ($uploadCount === 0) {
                 $attrs = array('style' => 'display:none');
             }
         }
         $html .= Html::openElement('h2', $attrs) . $msg . Html::closeElement('h2');
         $html .= '</div>';
     }
     return $html;
 }
Example #19
0
 /**
  * Creates account for new users
  */
 public function actionRegister()
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->request->redirect('/');
     }
     $user = new User('register');
     $profile = new UserProfile();
     if (Yii::app()->request->isPostRequest && isset($_POST['User'], $_POST['UserProfile'])) {
         $user->attributes = $_POST['User'];
         $profile->attributes = $_POST['UserProfile'];
         $valid = $user->validate();
         $valid = $profile->validate() && $valid;
         if ($valid) {
             $user->save();
             $profile->save();
             $profile->setUser($user);
             // Add user to authenticated group
             Yii::app()->authManager->assign('Authenticated', $user->id);
             $this->addFlashMessage(Yii::t('UsersModule.core', 'Спасибо за регистрацию на нашем сайте.'));
             // Authenticate user
             $identity = new UserIdentity($user->username, $_POST['User']['password']);
             if ($identity->authenticate()) {
                 Yii::app()->user->login($identity, Yii::app()->user->rememberTime);
                 Yii::app()->request->redirect($this->createUrl('/users/profile/index'));
             }
         }
     }
     $this->render('register', array('user' => $user, 'profile' => $profile));
 }
 /**
  * Constructor
  *
  * @param User    $user    the user for the feed
  * @param User    $cur     the current authenticated user, if any
  * @param boolean $indent  flag to turn indenting on or off
  *
  * @return void
  */
 function __construct($user, $cur = null, $indent = true)
 {
     parent::__construct($cur, $indent);
     $this->user = $user;
     if (!empty($user)) {
         $profile = $user->getProfile();
         $ao = ActivityObject::fromProfile($profile);
         array_push($ao->extra, $profile->profileInfo($cur));
         // XXX: For users, we generate an author _AND_ an <activity:subject>
         // This is for backward compatibility with clients (especially
         // StatusNet's clients) that assume the Atom will conform to an
         // older version of the Activity Streams API. Subject should be
         // removed in future versions of StatusNet.
         $this->addAuthorRaw($ao->asString('author'));
         $depMsg = 'Deprecation warning: activity:subject is present ' . 'only for backward compatibility. It will be ' . 'removed in the next version of StatusNet.';
         $this->addAuthorRaw("<!--{$depMsg}-->\n" . $ao->asString('activity:subject'));
     }
     // TRANS: Title in atom user notice feed. %s is a user name.
     $title = sprintf(_("%s timeline"), $user->nickname);
     $this->setTitle($title);
     $sitename = common_config('site', 'name');
     $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
     $this->setSubtitle($subtitle);
     $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
     $logo = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
     $this->setLogo($logo);
     $this->setUpdated('now');
     $this->addLink(common_local_url('showstream', array('nickname' => $user->nickname)));
     $self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom'));
     $this->setId($self);
     $this->setSelfLink($self);
     $this->addLink(common_local_url('sup', null, null, $user->id), array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'type' => 'application/json'));
 }
Example #21
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'delete_for_user':
             $input = $ma->getInput();
             if (isset($input['users_id'])) {
                 $user = new User();
                 $user->getFromDB($input['users_id']);
                 foreach ($ids as $id) {
                     if ($input['users_id'] == Session::getLoginUserID()) {
                         if ($item->deleteByCriteria(array('users_id' => $input['users_id'], 'itemtype' => $id))) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($user->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($user->getErrorMessage(ERROR_RIGHT));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
Example #22
0
 public function sendResetPasswordEmail($emailOrUserId)
 {
     $user = new User();
     $user->Load("email = ?", array($emailOrUserId));
     if (empty($user->id)) {
         $user = new User();
         $user->Load("username = ?", array($emailOrUserId));
         if (empty($user->id)) {
             return false;
         }
     }
     $params = array();
     //$params['user'] = $user->first_name." ".$user->last_name;
     $params['url'] = CLIENT_BASE_URL;
     $newPassHash = array();
     $newPassHash["CLIENT_NAME"] = CLIENT_NAME;
     $newPassHash["oldpass"] = $user->password;
     $newPassHash["email"] = $user->email;
     $newPassHash["time"] = time();
     $json = json_encode($newPassHash);
     $encJson = AesCtr::encrypt($json, $user->password, 256);
     $encJson = urlencode($user->id . "-" . $encJson);
     $params['passurl'] = CLIENT_BASE_URL . "service.php?a=rsp&key=" . $encJson;
     $emailBody = file_get_contents(APP_BASE_PATH . '/templates/email/passwordReset.html');
     $this->sendEmail("[" . APP_NAME . "] Password Change Request", $user->email, $emailBody, $params);
     return true;
 }
Example #23
0
function user_registration()
{
    $user = new User();
    global $main_db, $session;
    if (isset($_POST['action'])) {
        $fields = $_POST['fields'];
        $data = array();
        foreach ($fields as $field) {
            $data[$field['name']] = $field['value'];
        }
        $data['date_time'] = date('Y-m-d H:i:s');
        //       change password as md5 hahsing
        $data['password'] = md5($data['password']);
        /* Remove confirm password field*/
        $data['confirm-password'] = '';
        $data = array_filter($data);
        // If user already exists
        if ($user->check_duplicate_user($data['email_id'])) {
            echo 'duplicate';
        } else {
            //  Register as new user
            if ($user->register_admin($data)) {
                echo 'yes';
            } else {
                echo 'no';
            }
        }
    }
}
 public function testSet()
 {
     $lUser = new User();
     $lUser->setUsername('hugo');
     $lUser->setActive(true);
     $this->assertTrue(is_object(PersistentVariableTable::set('affen', $lUser, true)));
 }
Example #25
0
 function view($id = null, $name = null)
 {
     $comment = $this->Post->getComment("*", array("id" => $id));
     $user = new User();
     $comment['user_name'] = $user->getUser("name", array('user_id' => $comment["user_id"]));
     $this->set('comment', $comment);
 }
Example #26
0
 function profilesave()
 {
     $model = new User();
     $model->setUpdate();
     View::$layout = 'empty';
     View::render('site/redirect', array('text' => 'Данные успешно изменены', 'href' => '/cabinet/'));
 }
Example #27
0
 public function updateUserAction($yacPrefix, $key)
 {
     $yac = new Yac($yacPrefix);
     $ret = $yac->get($key);
     // Q: Does ttl expired key flushed or not?
     $user = new User();
     $user->name = $ret['param']['name'];
     $user->department = $ret['param']['department'];
     $success = $user->save();
     if ($success) {
         unset($user);
         // echo "Thanks for registering!\r\n";
     } else {
         echo "Sorry, {$yacPrefix}:::::::{$key} \r\n";
         foreach ($user->getMessages() as $message) {
             echo $message->getMessage(), "\r\n";
         }
     }
     if (!$ret) {
         var_export(array($key, $ret));
         echo "\r\n";
     }
     $yac->delete($key);
     return true;
     // $arr = unserialize($ret);
     // return array("heihei"=>$ret,"ret2"=>$ret2);
 }
Example #28
-1
 public function processAction()
 {
     $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('dbAdapter'));
     $authAdapter->setTableName('user')->setIdentityColumn('username')->setCredentialColumn('password')->setIdentity($_POST['username'])->setCredential($_POST['password']);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     $data = array();
     if ($result->isValid()) {
         unset($this->_session->messages);
         $identity = $auth->getIdentity();
         $user = new User();
         $user->username = $identity;
         $user->populateWithUsername();
         Zend_Auth::getInstance()->getStorage()->write($user);
         //$this->_redirect('login/complete');
         //$this->_forward('index','main');
         $data['msg'] = __("Login successful.");
         $data['code'] = 200;
     } else {
         $auth->clearIdentity();
         $this->_session->messages = $result->getMessages();
         //$this->_redirect('login');
         $data['err'] = __("Invalid username/password.");
         $data['code'] = 404;
     }
     header('Content-Type: application/xml;');
     $this->view->data = $data;
     $this->completeAction();
     //$this->render();
 }
 private function getUserName($uid)
 {
     require_once 'user.class.php';
     $currentUser = new User();
     $currentUser->uid = $uid;
     return json_decode($currentUser->getData(), true)['username'];
 }
Example #30
-4
 function processNewAdministrator()
 {
     global $interface;
     global $configArray;
     $login = $_REQUEST['login'];
     $newAdmin = new User();
     $barcodeProperty = $configArray['Catalog']['barcodeProperty'];
     $newAdmin->{$barcodeProperty} = $login;
     $newAdmin->find();
     if ($newAdmin->N == 1) {
         global $logger;
         $logger->log(print_r($_REQUEST['roles'], TRUE));
         if (isset($_REQUEST['roles'])) {
             $newAdmin->fetch();
             $newAdmin->roles = $_REQUEST['roles'];
             $newAdmin->update();
         } else {
             $newAdmin->fetch();
             $newAdmin->query('DELETE FROM user_roles where user_roles.userId = ' . $newAdmin->id);
         }
         global $configArray;
         header("Location: {$configArray['Site']['path']}/Admin/{$this->getToolName()}");
         die;
     } else {
         $interface->assign('error', 'Could not find a user with that barcode.');
         $interface->setTemplate('addAdministrator.tpl');
     }
 }