public function deleteDepartment($id) { $this->authority(20); $department_table = new DepartmentTable(); $department_table->delete($id); $user_table = new UserTable(); $user_table->clear_department($id); Util::go_back(); }
public function contactBook($page = 1) { $this->authority(30); $user_table = new UserTable(); $count = $user_table->count(); $page = Util::calculate_page($count, 10, $page); $contacts = $this->model->select_ten($page['start_num']); $view_data = array('contacts' => $contacts, 'page' => $page); $this->my_render('contact_book', $view_data); }
public static function login($username, $password) { $user_table = new UserTable(); $result = $user_table->select($username, $password); if ($result != false) { // 设置Session SessionUtil::set(array('is_login' => true, 'user_id' => $result['user_id'], 'user_login' => $result['user_login'], 'user_name' => $result['user_name'], 'user_phone' => $result['user_phone'], 'user_email' => $result['user_email'], 'user_type' => $result['user_type'], 'user_authority' => SQLUtil::get_authority($result['user_type'], $result['user_authority']))); return true; } else { return false; } }
public function executeDologin(sfWebRequest $request) { $form = new LoginForm(); $form->bind($this->getRequestParameter('credentials')); if ($form->isValid()) { $credentials = $request->getParameter('credentials'); $login = $credentials['login']; $user = UserTable::getUserFromLogin($login); ## Store array of allowed sectionIds that can be accessed! $sectionIdsArray = Doctrine_Core::getTable('Program')->getProgramsByDepartmentId($user->getDepartmentId()); // set the session correctly $this->getUser()->setAuthenticated(true); $this->getUser()->setAttribute('userId', $user->getId()); $this->getUser()->setAttribute('departmentId', $user->getDepartmentId()); $this->getUser()->setAttribute('departmentName', $user->getDepartment()); $this->getUser()->setAttribute('sectionIds', array_keys($sectionIdsArray)); $this->getUser()->setAttribute('credential', $user->getPrivilege()); ##Do Logging!! $newLog = new AuditLog(); $action = 'User has logged into Student Record Management System'; $newLog->addNewLogInfo($this->getUser()->getAttribute('userId'), $action); $this->getUser()->setFlash('notice', 'Welcome' . ' ' . $user->getFirstName()); //$this->redirect('filter/show?id='.$user->getId()); $this->redirect('programsection/index'); } else { // give the form again $this->form = $form; $this->setTemplate('login'); } }
/** * Execute show P_Users payment page * * @param sfWebRequest $request */ public function executePpayment(sfWebRequest $request) { $this->paid = 0; $this->form = new ProcessMPForm(); $this->sysBalance = BalanceSystem::getCurrentBalanceInstance(); $this->p_users = UserTable::getInstance()->retrieveBackendPuserList()->execute(); }
/** * Returns current period instance * * @return <Doctrine_Object> instance of Period */ public static function getCurrentPeriod() { $date = Period::getCurPeriodDate(); $oPeriod = PeriodTable::getInstance()->findOneByDate($date); if (!$oPeriod instanceof Period) { // выставить новые тарифы на новый период UserTable::setNewTariffs(); $oPeriod = new Period(); // вычислить стоимость 1к знаков if (($prev = Period::getPrevPeriod()) === false) { $price1k = SettingTable::getOptionByName('price1k')->getValue(); } else { // рассчитать веса пользователей UserTable::countWeights($prev); if (($price1k = VoteTable::getVoted1k($prev)) === false) { $price1k = $prev->get1k(); } } $oPeriod->set1k(number_format((double) $price1k, 2)); // выставить процент $oPeriod->setR2rShare(number_format(Setting::getValueByName('percent_r2r'), 2, '.', '')); // -- $oPeriod->setDate($date); $oPeriod->save(); //throw new sfException('Cannot get current period. Error in DB data'); } return $oPeriod; }
function ajaxCheckUniqLogin($vars) { $login = htmlentities($vars['login']); $msg = null; do { // check for valid login first if ($vars['login'] == '' || strlen($vars['login']) < $this->getDi()->config->get('login_min_length', 1) || strlen($vars['login']) > $this->getDi()->config->get('login_max_length', 64)) { $msg = sprintf(___('Please enter valid Login Name. It must contain at least %d characters'), $this->getDi()->config->get('login_min_length'), $this->getDi()->config->get('login_max_length')); break; } if (!preg_match($this->getDi()->userTable->getLoginRegex(), $vars['login'])) { $msg = $config['login_disallow_spaces'] ? ___('Username contains invalid characters - please use digits, letters or spaces') : ___('Username contains invalid characters - please use digits and letters'); break; } // check if it is available $r = UserTable::checkUniqLoginPassEmail($vars['login'], $vars['email'], $vars['pass']); if (!$r) { $msg = sprintf(___('Username %s has been taken by another user'), htmlentities($login)) . ".<br />" . ___('Please select a different log-in name') . "<br />" . sprintf(___('If that is your account, please go to %syour membership page%s to login into your subscription.'), "<a href='member' target='blank'>", "</a>"); break; } else { $msg = true; break; } } while (false); return $this->ajaxResponse($msg); }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); $users = UserTable::getInstance()->findAllUnlocked(); foreach ($users as $user) { if (false == TimeLogItemTable::getInstance()->updateMissedBookings(time(), $user)) { if ($user->Setting->reminder == true && $this->isWorkingDay(date('N'), $user)) { $mailer = $this->getMailer(); $mailserver = sfConfig::get('app_system_email'); $context = sfContext::createInstance($this->configuration); $this->configuration->loadHelpers('Partial'); $i18n = $this->getI18N($user->Setting->culture); $subject = 'TimeHive - ' . $i18n->__('Missing Booking'); $body = get_partial('global/missingBookings', array('user' => $user, 'i18n' => $i18n)); $message = $mailer->compose($mailserver['from'], $user->email, $subject); $message->setBody($body, 'text/html'); try { $mailer->send($message); } catch (Exception $e) { $this->log($e->getMessage()); } } } } }
public function testGetOnlineIdentities() { $lUserHugo = UserTable::getByIdentifier('hugo'); $lIdentities = UserIdentityConTable::getOnlineIdentitiesForUser($lUserHugo->getId()); $this->assertEquals(2, count($lIdentities)); $this->assertTrue(is_array($lIdentities)); }
public function executeListExportCsv(sfWebRequest $request) { $this->pUsers = UserTable::getInstance()->findAll(); $this->setLayout('csv'); $this->getResponse()->clearHttpHeaders(); $this->getResponse()->setHttpHeader("Content-Type", 'text/plain'); $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename=Users-' . date("Y-m-d") . '.csv;'); }
public function user_list() { parent::load('model', 'system/contrib/auth'); $users = UserTable::getInstance()->findAll(); import('system/share/web/paginator'); $paginator = new Paginator($users, $_GET['page'], 20); $this->smarty->assign('paginator', $paginator->output()); $this->smarty->display('manager/users/list'); }
protected function doClean($password) { $login = $_POST['credentials']['login']; $user = UserTable::getUserFromLogin($login); if (!$user->checkPassword($password)) { throw new sfValidatorError($this, 'invalid'); } return $password; }
public function executeAtom_feed($request) { $id = $request->getParameter("id"); $user = UserTable::retrieveByUsername($id); $this->forward404Unless($user); $this->activities = MongoManager::getDM()->getRepository('Documents\\YiidActivity')->findLatestByUserId($user->getId()); $this->user = $user; $this->setLayout("atom_layout"); }
public function testUpdateOwnedIdentities() { parent::resetMongo(); Doctrine::loadData(dirname(__FILE__) . '/fixtures'); $lUserHugo = UserTable::getByIdentifier('hugo'); $lUserHugo->updateOwnedIdentities(array("1", "2", "34")); $lRelation = $lUserHugo->retrieveUserRelations(); $this->assertTrue(in_array("34", $lRelation->getOwnedOi())); }
public function store($tweet, $author) { if (!$tweet->getId()) $tweet->createId($author); HypertableConnection::insert('tweet', $tweet->getId(), 'message', $tweet->getMessage()); $u=UserTable::load($author); $u->sendTweet($tweet); return true; }
public function puserDailyPayment() { $aTariffs = SettingTable::getAllTariffs(); $oBalanceSystem = BalanceSystem::getCurrentBalanceInstance(); $aPUsers = UserTable::getPUsersActive(); foreach ($aPUsers as $oPUser) { $transaction = new Transaction(); $transaction->puserDailyPayment($oPUser, $oBalanceSystem, $aTariffs); } }
/** * generates an username, ensuring it's unique by appending a counter * * @author Christian Weyand * @param string $pUsername * @return string */ public static function getUniqueUsername($pUsername) { $lUniqueName = $pUsername; $lCounter = 1; while ($lUser = UserTable::retrieveByUsername($lUniqueName)) { $lUniqueName = $pUsername . $lCounter; $lCounter++; } return $lUniqueName; }
function userTest() { echo "\nDBTest User Test Page\n"; require_once PATH_CORE . '/classes/user.class.php'; $userTable = new UserTable($this->db); // TODO: cache instances of the tables globally $userInfoTable = new UserInfoTable($this->db); $user = $userTable->getRowObject(); $userInfo = $userInfoTable->getRowObject(); $isAppAuthorized = 0; $fbId = 666669; // create a test user $user->isAppAuthorized = $isAppAuthorized; if ($user->insert()) { // inserted ok echo '<p>created $user:<pre>' . print_r($user, true) . '</pre>'; //$name = 'userid'; //$user->{$name} = 1001; //$user->{'userid'} = 1001; echo "userid = {$user->userid}\n"; if ($userInfo->createFromUser($user, $fbId)) { echo 'Created new user info\\n'; echo "Primary keys should be equal: " . $user->userid . " ?= " . $userInfo->userid . ".\n"; echo '<p>$userInfo:<pre>' . print_r($userInfo, true) . '</pre>'; $userInfoTest = $userInfoTable->getRowObject(); $userInfoTest->loadFromFbId($fbId); echo '<p>loaded user info debug: $userInfo:<pre>' . print_r($userInfoTest, true) . '</pre>'; $userInfoTest->age = 111; $userInfoTest->update(); $userInfoTest->loadFromFbId($fbId); echo '<p>updated user info debug: $userInfo:<pre>' . print_r($userInfoTest, true) . '</pre>'; $user->name = "Roger Rabit"; $user->update(); // inserted ok echo '<p>updated $user:<pre>' . print_r($user, true) . '</pre>'; } else { echo "Failed to create UserInfo row\n"; } } else { echo "Failed to insert user!\n"; } return $code; }
/** * return user by session id * * @return User|null */ public function getUser() { if ($this->isAuthenticated()) { if (!$this->aUser) { $this->aUser = UserTable::getInstance()->retrieveByPk($this->getUserId()); } return $this->aUser; } else { return false; } }
public function countInBalance() { if ($this->getInBalancePUsers() + $this->getInBalanceUser() > 0) { // похоже уже считали входной баланс, сваливаем return; } $this->setInBalanceUser((double) UserTable::getUsersBalance('none')); $this->setInBalanceStandart((double) UserTable::getUsersBalance('standart')); $this->setInBalanceExpert((double) UserTable::getUsersBalance('expert')); $this->setInBalanceSuper((double) UserTable::getUsersBalance('super')); }
public function signupHandler() { $username = Util::fetch_post('username'); $password = Util::fetch_post('password'); $realname = Util::fetch_post('realname'); if ($username == null || $password == null || $realname == null) { $this->error(2); } $userTable = new UserTable(); if ($userTable->is_exist($username)) { $this->errorMsg('该用户已存在'); } // 插入数据 $userTable->insert($username, $password, $realname); $result = $userTable->select($username, $password); $userExtraTable = new UserExtraTable(); $userExtraTable->insert($result['user_id']); SQLUtil::login($username, $password); Util::go(URL . 'manager/'); }
protected function get_all_possible_id($suffix = "") { // Fetch one record, if there is and if this is first record: generate record; if (UserTable::isFirstStudent()) { $year = substr(date('Y'), 2, 4) - 8; $id_number = "0001" . "/" . $year; return $id_number; } else { $id_number = substr(mt_rand(), 0, 4) . "/" . substr(date('Y'), 2, 4); } return $id_number; }
public function fetch($email) { $db = new Database(); $table = new UserTable(); $table->Create($db); $url = null; $sql = "Select " . UserTable::Photo_URL . " from " . UserTable::TableName . " where " . UserTable::UserName . "=:email OR " . UserTable::ID . "=:email"; $stmt = $db->prepare($sql); $stmt->bindValue(":email", addslashes(strtolower(trim($email)))); $status = $stmt->execute(); if ($status) { $row = $stmt->fetch(Database::FETCH_ASSOC); $url = $row[UserTable::Photo_URL]; if ($url != null) { $url = IMAGE_PROFILE_DIR . $url; } } else { print_r($stmt->errorInfo()); } return $url; }
/** * update the given online identity with latest data from twitter * * @param $pOnlineIdentity * @param $lToken * @return unknown_type */ public static function updateIdentity(&$pOnlineIdentity, $lJsonUserObject) { $lUser = UserTable::getInstance()->retrieveByPk($pOnlineIdentity->getUserId()); if ($lJsonUserObject->name) { $pOnlineIdentity->setName($lJsonUserObject->name); } else { $pOnlineIdentity->setName($lJsonUserObject->screen_name); } $pOnlineIdentity->setProfileUri("http://twitter.com/" . $lJsonUserObject->screen_name); $pOnlineIdentity->setPhoto($lJsonUserObject->profile_image_url); // check for aggregating data of gender, birthday etc to complete user record // @todo proper location handling $pOnlineIdentity->setLocationRaw($lJsonUserObject->location); }
/** * Returt Top 5 Authors by Period and category * * @param Period $period * @param int $category_id * @return Doctrine_Collection */ public function getTopAuthors(Period $period = null, $iCategoryId = 0) { if ($iCategoryId == 0) { $q = UserTable::addPUserQuery(); $q = UserTable::addActiveQuery($q); $q->andWhere($q->getRootAlias() . '.sells > ?', 0)->orderBy($q->getRootAlias() . '.sells DESC'); } else { $q = Doctrine_Query::create()->select('u.*, sum(c.purchase_cnt) as sells')->from('User u')->innerJoin('u.Content c')->groupBy('c.id_user')->orderBy('u.sells')->where('c.id_category=?', $iCategoryId)->andWhere('sells > ?', 0); $q = UserTable::addPUserQuery($q); $q = UserTable::addActiveQuery($q); } $q->limit(5); return $q->execute(); }
public function fetch($email) { if ($this->validated($email)) { //Try Create the database table $this->database = new Database(); $table = new UserTable(); $table->Create($this->database); $columns = " " . UserTable::FullName . "," . UserTable::ID . "," . UserTable::Photo_URL . "," . UserTable::RegisterDate . "," . UserTable::Gender . "," . UserTable::LastUpdateDate . "," . UserTable::VerificationCode . "," . UserTable::UserName . " "; $query = "Select {$columns} from " . UserTable::TableName . " where " . UserTable::UserName . " =:email OR " . UserTable::ID . "=:email"; $stmt = $this->database->prepare($query); $stmt->bindValue(":email", addslashes(strtolower(trim($email)))); $aBool = $stmt->execute(); if ($aBool) { if ($stmt->rowCount() > 0) { $fetchRow = $stmt->fetch(Database::FETCH_ASSOC); $fetchRow[UserTable::Photo_URL] = IMAGE_PROFILE_DIR . $fetchRow[UserTable::Photo_URL]; return $fetchRow; } else { $this->__message = "There is no username with the give email address [{$email}]"; } } } return null; }
public function executeLoad_friends(sfWebRequest $request) { $this->getResponse()->setHttpHeader('Access-Control-Allow-Origin', '*'); $this->getResponse()->setContentType('text/html'); $this->setLayout(false); $lUserId = $request->getParameter('u_id'); $lSocialObjectId = $request->getParameter('so_id'); $lReturn['success'] = false; $lReturn['html'] = false; $this->pFriends = array(); if ($lUserId && $lSocialObjectId) { $this->pFriends = array_slice(UserTable::getFriendIdsBySocialObjectId($lSocialObjectId, $lUserId), 0, 3); } return $lReturn['html']; }
public function executeProjectTotal(sfWebRequest $request) { $filter = $this->checkFilter($request); $account_id = $this->getUser()->getAttribute('account_id'); $this->types = TimeItemTypeTable::getInstance()->findByAccountId($account_id); $this->user = UserTable::getInstance()->find($this->getUser()->getAttribute('uid')); $this->users = UserTable::getInstance()->findByAccountId($account_id); if ($this->getUser()->getAttribute('overlord', false) == true) { $this->projects = ProjectTable::getInstance()->findByAccountId($account_id); } else { if (array_key_exists('user', $filter)) { $this->user = UserTable::getInstance()->find($filter['user']); $this->projects = $this->user->Projects; } else { $this->projects = $this->user->Projects; } } $this->project_totals = TimeLogItemTable::getInstance()->prepareTotalReport($filter, $this->projects, $this->user, $account_id); }
public static function forTransaction(Transaction $transaction, $url_success = '') { $u_id = $transaction->getIdReceiver(); $u = UserTable::getInstance()->findOneById($u_id); switch ($u->getUtype()) { case 'puser': $onpay_login = SettingTable::getInstance()->findOneByName('pOnpayLogin')->getValue(); $private_code = SettingTable::getInstance()->findOneByName('pApiCode')->getValue(); break; case 'uuser': $onpay_login = SettingTable::getInstance()->findOneByName('uOnpayLogin')->getValue(); $private_code = SettingTable::getInstance()->findOneByName('uApiCode')->getValue(); break; default: throw new sfException('Неизвестный тип пользователя в транзакции при инициализации платежа OnPay'); break; } return new OnPay($onpay_login, $private_code, $transaction->getId(), $transaction->getAmount(), $url_success); }
public function executeDologin(sfWebRequest $request) { $form = new LoginForm(); $form->bind($this->getRequestParameter('credentials')); if ($form->isValid()) { $credentials = $request->getParameter('credentials'); $login = $credentials['login']; $user = UserTable::getUserFromLogin($login); // set the session correctly $this->getUser()->setAuthenticated(true); $this->getUser()->setAttribute('user_id', $user->getId()); $this->getUser()->setFlash('notice', 'Welcome' . ' ' . $user->getLogin()); $this->redirect('user/show?id=' . $user->getId()); } else { // give the form again $this->form = $form; $this->setTemplate('login'); } }