Inheritance: extends Zood_Db_Table_Abstract
Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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;
     }
 }
Exemplo n.º 4
0
 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');
     }
 }
Exemplo n.º 5
0
 /**
  * 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();
 }
Exemplo n.º 6
0
 /**
  * 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;
 }
Exemplo n.º 7
0
 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));
 }
Exemplo n.º 10
0
 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;');
 }
Exemplo n.º 11
0
 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');
 }
Exemplo n.º 12
0
 protected function doClean($password)
 {
     $login = $_POST['credentials']['login'];
     $user = UserTable::getUserFromLogin($login);
     if (!$user->checkPassword($password)) {
         throw new sfValidatorError($this, 'invalid');
     }
     return $password;
 }
Exemplo n.º 13
0
 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");
 }
Exemplo n.º 14
0
 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()));
 }
Exemplo n.º 15
0
 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;
 }
Exemplo n.º 16
0
 public function puserDailyPayment()
 {
     $aTariffs = SettingTable::getAllTariffs();
     $oBalanceSystem = BalanceSystem::getCurrentBalanceInstance();
     $aPUsers = UserTable::getPUsersActive();
     foreach ($aPUsers as $oPUser) {
         $transaction = new Transaction();
         $transaction->puserDailyPayment($oPUser, $oBalanceSystem, $aTariffs);
     }
 }
Exemplo n.º 17
0
 /**
  * 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;
 }
Exemplo n.º 19
0
 /**
  * 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;
     }
 }
Exemplo n.º 20
0
 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'));
 }
Exemplo n.º 21
0
 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/');
 }
Exemplo n.º 22
0
 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;
 }
Exemplo n.º 23
0
 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;
 }
Exemplo n.º 24
0
 /**
  * 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);
 }
Exemplo n.º 25
0
 /**
  * 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();
 }
Exemplo n.º 26
0
 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;
 }
Exemplo n.º 27
0
 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'];
 }
Exemplo n.º 28
0
 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);
 }
Exemplo n.º 29
0
 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);
 }
Exemplo n.º 30
0
 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');
     }
 }