/** * 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(); }
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 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'); }
/** * 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; } }
/** * 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); }
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 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 function setUp() { //parent::resetMongo(); sfConfig::set('sf_environment', 'test'); Doctrine::loadData(dirname(__FILE__) . '/fixtures'); sfConfig::set('sf_environment', 'dev'); $this->table = Doctrine::getTable('Deal'); $this->deal1 = $this->table->findOneBy('name', 'Campaign No. 1'); $this->deal2 = $this->table->findOneBy('name', 'Campaign No. 2'); $this->deal3 = $this->table->findOneBy('name', 'Campaign No. 3'); $this->deal4 = $this->table->findOneBy('name', 'Campaign No. 4'); $this->deal5 = $this->table->findOneBy('name', 'Campaign No. 5'); $this->deal6 = $this->table->findOneBy('name', 'Campaign No. 6'); $this->deal7 = $this->table->findOneBy('name', 'Campaign No. 7'); $this->dealCommission1 = $this->table->findOneBy('name', 'Campaign No. Commission 1'); $this->dealCommission2 = $this->table->findOneBy('name', 'Campaign No. Commission 2'); $this->dealCommission3 = $this->table->findOneBy('name', 'Campaign No. Commission 3'); $this->hugo = UserTable::getInstance()->findOneByUsername('hugo'); $this->affe = UserTable::getInstance()->findOneByUsername('affe'); }
public function executeUpdate($request) { $time_values = $request->getParameter('time', array()); $user = UserTable::getInstance()->find($this->getUser()->getAttribute('uid')); $this->time_values = $time_values; for ($i = 1; $i <= 7; $i++) { if (!array_key_exists($i, $time_values)) { continue; } $projects = $time_values[$i]; $booking_timestamp = $request->getParameter('weekstart') + ($i - 1) * 24 * 60 * 60; $booking_date = date("Y-m-d", $booking_timestamp); if ($booking_timestamp < time()) { foreach ($projects as $pid => $project) { $query = new Doctrine_Query(); $query->delete('TimeLogItem ti')->where('ti.user_id=? AND ti.project_id=? AND ti.itemdate=?', array($this->getUser()->getAttribute('uid'), $pid, $booking_date))->execute(); for ($time_index = 0; $time_index < count($project['time']); $time_index++) { $time_value = $project['time'][$time_index]; $time_type = $project['type'][$time_index]; $time_comment = $project['comment'][$time_index]; if ($time_value != "" && $time_value != 0) { $type_query = new Doctrine_Query(); $type = $type_query->from('TimeItemType tit')->where('tit.name=?', array($time_type))->fetchOne(); $current_value = new TimeLogItem(); $current_value->value = $time_value; $current_value->itemdate = $booking_date; $current_value->user_id = $this->getUser()->getAttribute('uid'); $current_value->project_id = $pid; $current_value->type_id = $type->id; $current_value->note = $time_comment; $current_value->save(); } } } TimeLogItemTable::getInstance()->updateMissedBookings($booking_timestamp, $user); } } $this->getUser()->setFlash('saved.success', 1); $this->redirect('timesheet/index?year=' . $request->getParameter('year', date('Y')) . '&week=' . $request->getParameter('week', date('W'))); }
/** * Action Login implementation * * @param sfWebRequest $request */ public function executeLogin($request) { $username = $request->getParameter('username', ''); $password = $request->getParameter('password', ''); $user = UserTable::getInstance()->login($username, $password); if ($user) { if ($user->locked) { $this->getUser()->setAuthenticated(false); $this->getUser()->setFlash('login_failure.locked', true); $this->redirect('login/index'); } $this->getUser()->signIn($user); if ($request->getParameter('autologin', 0) == 1) { $token = TokenTable::getInstance()->createAutologinToken($user->id); $token->save(); $this->response->setCookie('autologin', $token->value, time() + sfConfig::get('app_autologin_expiration')); } $this->redirect('dashboard/index'); } else { $this->getUser()->setAuthenticated(false); $this->getUser()->setFlash('login_failure', true); $this->forward('login', 'index'); } }
public function getUserObject() { if ($this->user != null) { return $this->user; } return UserTable::getInstance()->find($this->getAttribute('uid')); }
<i class="icon-tags"></i> <?php echo simple_tag_list($activity->getTags(), array("separator" => ","), "shares/index?t="); ?> <?php } ?> </div> <div class="span3"> <h3>Who shared this site?</h3> <ul class="users"> <?php foreach ($social_object->getUids() as $user_id) { ?> <?php if ($user = UserTable::getInstance()->find($user_id)) { ?> <li> <?php if ($user->getProfileUrl()) { ?> <a href="<?php echo $user->getProfileUrl(); ?> "><?php } ?> <?php echo image_tag($user->getAvatar(), array("title" => $user->getFullname(), "alt" => "Image of " . $user->getFullname())); ?> <?php
public function executeUnlock(sfWebRequest $request) { $user = UserTable::getInstance()->find($request->getParameter('id')); $this->forward404Unless($user); if ($user->account_id != $this->getUser()->getAttribute('account_id')) { $this->redirect('default/secure'); } if ($user->Account->hasEnoughLicensesToAddUser() == false) { $this->getUser()->setFlash('error.license_count', 1); } else { $user->locked = false; $user->save(); } $this->redirect('adminUser/list'); }
public function setUserContentRating($iUserId, $iTranslateRate) { $oPeriod = Period::getCurrentPeriod(); $oUser = UserTable::getInstance()->findOneById($iUserId); if (!($oContentRating = $oUser->hasRateTranslate($this->getId()))) { $oContentRating = new ContentRating(); $oContentRating->setContentId($this->getId()); $oContentRating->setPeriodId($oPeriod->getId()); $oContentRating->setUserId($iUserId); } $oContentRating->setContentRating($iTranslateRate); $oContentRating->save(); $aArticles = ContentRatingTable::getInstance()->getRatesByArticle($this->getId(), $oPeriod->getId()); $iSum = 0; foreach ($aArticles as $oRating) { $iSum += $oRating->getContentRating(); } $this->setContRate($iSum / $aArticles->count()); $this->save(); }
/** * lazy loads the user connected to this activity * * @return User */ public function getUser() { $lUser = \UserTable::getInstance()->retrieveByPk($this->getUserId()); return $lUser; }
/** * returns an array with userid's of your friends, who acted on a given social object * * @param string $pSocialObjectId * @param int $pUserId * @return array() * @author weyandch */ public static function getFriendIdsBySocialObjectId($pSocialObjectId, $pUserId) { $dm = MongoManager::getDM(); $lSocialObject = $dm->getRepository('Documents\\SocialObject')->find($pSocialObjectId); $lUser = UserTable::getInstance()->find($pUserId); $lConnectedUsers = $lUser->getIdsOfFriends(); array_unshift($lConnectedUsers, $lUser->getId()); $lFriendsActive = array(); if ($lSocialObject && $lConnectedUsers) { $lFriendsActive = array_intersect($lConnectedUsers, $lSocialObject->getUids()); } return $lFriendsActive; }
public function addFundsFin() { if ($this->isNew() or $this->getIsPaid()) { // транзакция новая или уже проведена return false; } $balance = UserTable::getInstance()->findOneById($this->getIdReceiver())->getBalans(); $this->setSenderBalanceBefore($balance); $this->setReceiverBalanceBefore($balance); $this->setSenderBalanceAfter($this->getSenderBalanceBefore() + $this->getAmount()); $this->setReceiverBalanceAfter($this->getReceiverBalanceBefore() + $this->getAmount()); $this->setIsPaid(true); $this->save(); return true; }
include_partial('widget_piechart', array('title' => 'Services', 'data' => $data, 'type' => 'services')); ?> </section> <section class="main-section list-section clearfix"> <div class="widget widget-single widget-one-section"> <header><section>Powerliker</section></header> <section class="widget-data-section"> <ol class="widget-ordered-list" style="list-style-type: none;"> <?php foreach ($data['top_users'] as $item) { ?> <li class="small" style="margin: 0 0 5px 0;"><img style="vertical-align: middle; margin-right: 5px; max-height: 16px; max-width: 16px;" src="<?php echo UserTable::getInstance()->find($item['u_id'])->getAvatar(); ?> " /> <?php echo UserTable::getInstance()->find($item['u_id'])->getFullname(); ?> (<?php echo $item['count']; ?> )</li> <?php } ?> </ol> </section> <footer> Powered by @Spreadly </footer> </div>
public function change_password() { parent::load('model', 'system/contrib/auth.User'); $user = UserTable::getInstance()->find(User::info('id')); import('system/share/network/redirect'); if ($this->is_post()) { list($func, $random, $encryped) = explode('$', $user->password); /* * 验证原密码 */ if ($user->password && $user->password === User::generate_password($_POST['old_password'], $random, $func)) { $user->password = User::generate_password($_POST['new_password']); $user->save(); User::logout(); $message = '修改密码成功, 请重新登录'; HTTPRedirect::flash_to(url_reverse('auth_login'), $message, $this->smarty); } else { $message = '原密码不正确, 请重试'; HTTPRedirect::flash_to('accounts/change_password', $message, $this->smarty); } } $this->smarty->display('auth/change_password'); }
echo __('Maximale Reichweite der Empfehlung'); ?> "> <?php echo __('Reach'); ?> </span> </div> </th> </tr> </thead> <tbody> <?php if ($pUrls->hasNext()) { foreach ($pUrls as $url) { $user = UserTable::getInstance()->find($url->getUserId()); ?> <tr> <td align="center" valign="middle" class="first"><div class="infname"><span><?php echo image_tag($user->getAvatar(), array("alt" => $user->getFullname(), "width" => 16, "height" => 16)); echo $user->getFullname(); ?> </span></div></td> <td align="center" valign="middle"><div><strong class="big-font blue"><?php echo $url->getAge(); ?> </strong></div></td> <td align="center" valign="middle"><div><strong class="big-font blue"><?php echo __($url->getGender()); ?> </strong></div></td>
/** * * @param <type> $utype * @return <type> */ public function getUserSellPurchaseSum($utype, $period = 0) { $q = UserTable::getInstance()->getBalanceUserFieldSum('sell_purchase_cnt'); $q->andWhere('u.utype=?', $utype); if ($period > 0) { $q->andWhere('id_period = ?', $period); } $resultSet = $q->execute(); return $resultSet->getFirst()->getSellPurchaseCntSum(); }
<?php use_helper('Avatar'); $count = 1; ?> <ul class="icons"> <?php foreach ($pFriends as $lUserId) { ?> <?php $lUser = UserTable::getInstance()->find($lUserId); ?> <li <?php if ($count >= 3) { echo 'class="last"'; } ?> ><?php echo avatar_tag($lUser->getAvatar(), 30, array('alt' => $lUser->getFullname(), 'title' => $lUser->getFullname(), 'class' => '', 'rel' => '')); ?> </li> <?php $count++; ?> <?php } ?> </ul>
<ul class="errors"> <?php foreach ($pErrors as $e) { $user = UserTable::getInstance()->find($e->getUId()); ?> <li> <small class="meta"><?php echo $e->getC()->format("d.m.Y @ H:i:s"); ?> <br /> <?php echo OnlineIdentityTable::getInstance()->find($e->getOiId())->getProfileUri(); ?> <?php if ($user && $user->getEmail()) { echo "<br />" . $user->getEmail(); } ?> </small> <h3> <strong><em><?php echo $user ? $user->getFullname() : 'n/a'; ?> </em></strong>s <strong><em><?php echo OnlineIdentityTable::getInstance()->find($e->getOiId())->getCommunity()->getName(); ?> </em></strong>-account has hiccups </h3> <p>Error: {<?php echo $e->getCode();
private function calc($range, $lastRange) { $data = array(); $data['current_user_count'] = UserTable::getInstance()->countByRange($range[0], $range[1]); $data['last_user_count'] = UserTable::getInstance()->countByRange($lastRange[0], $lastRange[1]); $data['user_count_delta'] = $this->delta($data['current_user_count'], $data['last_user_count']); $data['current_stats_user_count'] = SfGuardUserTable::getInstance()->countByRange($range[0], $range[1]); $data['last_stats_user_count'] = SfGuardUserTable::getInstance()->countByRange($lastRange[0], $lastRange[1]); $data['stats_user_count_delta'] = $this->delta($data['current_stats_user_count'], $data['last_stats_user_count']); $data['current_likes_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countByRange($range[0], $range[1]); $data['last_likes_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countByRange($lastRange[0], $lastRange[1]); $data['likes_count_delta'] = $this->delta($data['current_likes_count'], $data['last_likes_count']); $data['current_cbl_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countCBLByRange($range[0], $range[1]); $data['last_cbl_count'] = MongoManager::getDm()->getRepository('Documents\\YiidActivity')->countCBLByRange($lastRange[0], $lastRange[1]); $data['cbl_count_delta'] = $this->delta($data['current_cbl_count'], $data['last_cbl_count']); $data['current_domain_count'] = DomainProfileTable::getInstance()->countByRange($range[0], $range[1]); $data['last_domain_count'] = DomainProfileTable::getInstance()->countByRange($lastRange[0], $lastRange[1]); $data['domain_count_delta'] = $this->delta($data['current_domain_count'], $data['last_domain_count']); $data['current_verified_domain_count'] = DomainProfileTable::getInstance()->countVerifiedByRange($range[0], $range[1]); $data['last_verified_domain_count'] = DomainProfileTable::getInstance()->countVerifiedByRange($lastRange[0], $lastRange[1]); $data['verified_domain_count_delta'] = $this->delta($data['current_verified_domain_count'], $data['last_verified_domain_count']); $data['current_stats'] = MongoManager::getStatsDm()->getRepository('Documents\\AnalyticsActivity')->findOnlyByRange($range[0], $range[1]); $data['last_stats'] = MongoManager::getStatsDm()->getRepository('Documents\\AnalyticsActivity')->findOnlyByRange($lastRange[0], $lastRange[1]); $data['current_stats'] = $data['current_stats'] && $data['current_stats']->hasNext() ? $data['current_stats']->getNext() : null; $data['last_stats'] = $data['last_stats'] && $data['last_stats']->hasNext() ? $data['last_stats']->getNext() : null; $data['current_clickback_count'] = $data['current_stats'] ? $data['current_stats']['value']['cb'] : 0; $data['last_clickback_count'] = $data['last_stats'] ? $data['last_stats']['value']['cb'] : 0; $data['clickback_count_delta'] = $this->delta($data['current_clickback_count'], $data['last_clickback_count']); $data['current_media_penetration_count'] = $data['current_stats'] ? $data['current_stats']['value']['mp'] : 0; $data['last_media_penetration_count'] = $data['last_stats'] ? $data['last_stats']['value']['mp'] : 0; $data['media_penetration_count_delta'] = $this->delta($data['current_media_penetration_count'], $data['last_media_penetration_count']); $data['share_distribution'] = $data['current_stats'] ? array($data['current_stats']['value']['s']['facebook'] ? $data['current_stats']['value']['s']['facebook']['l'] : 0, $data['current_stats']['value']['s']['twitter'] ? $data['current_stats']['value']['s']['twitter']['l'] : 0, $data['current_stats']['value']['s']['linkedin'] ? $data['current_stats']['value']['s']['linkedin']['l'] : 0, $data['current_stats']['value']['s']['google'] ? $data['current_stats']['value']['s']['google']['l'] : 0) : array(0, 0, 0, 0); $data['share_distribution_labels'] = array('Fb:' . $data['share_distribution'][0], 'Tw:' . $data['share_distribution'][1], 'Li:' . $data['share_distribution'][2], 'Go:' . $data['share_distribution'][3]); if ($this->range == 'today' || $this->range == 'yesterday') { $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\ActivityStats")->findByRangeGroupByDay($range[0], $range[1]); $h = null; if ($lActivityStats && $lActivityStats->hasNext()) { $temp = $lActivityStats->getNext(); $h = $temp['value']['h']; unset($h['php_ckuf']); } $data['current_likes_range'] = $h ? $h : array(); $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\DealStats")->findByRangeGroupByDay($range[0], $range[1]); $h = null; if ($lActivityStats && $lActivityStats->hasNext()) { $temp = $lActivityStats->getNext(); $h = $temp['value']['h']; unset($h['php_ckuf']); } $data['current_deals_range'] = $h ? $h : array(); } else { $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\ActivityStats")->findLikesByRangeGroupByDay($range[0], $range[1]); if ($lActivityStats) { $lActivityStats = $lActivityStats->toArray(); $data['current_likes_range'] = array_values($this->padLikes($lActivityStats, date('c', $range[0]), date('c', $range[1]))); $lActivityStats = MongoManager::getStatsDm()->getRepository("Documents\\DealStats")->findLikesByRangeGroupByDay($range[0], $range[1]); $lActivityStats = $lActivityStats->toArray(); $data['current_deals_range'] = array_values($this->padLikes($lActivityStats, date('c', $range[0]), date('c', $range[1]))); } } $data['top_users'] = array_slice(MongoManager::getStatsDm()->getRepository("Documents\\AnalyticsActivity")->groupByUsers($range[0], $range[1]), 0, 5); $data['top_hosts'] = array_slice(MongoManager::getStatsDm()->getRepository("Documents\\AnalyticsActivity")->groupByHosts($range[0], $range[1]), 0, 5); $data['top_urls'] = array_slice(MongoManager::getStatsDm()->getRepository("Documents\\AnalyticsActivity")->groupByUrls($range[0], $range[1]), 0, 5); //$cb = new Chartbeat(); //$data['current_popup_visitors_count'] = $cb->getVisitorsByDate($this->range); $data['current_pi_count'] = intval(VisitTable::countPisForDay($range[0])); $data['last_pi_count'] = intval(VisitTable::countPisForDay($lastRange[0])); $data['pi_count_delta'] = $this->delta($data['current_pi_count'], $data['last_pi_count']); $data['current_conversion'] = $this->conversion($data['current_likes_count'], $data['current_pi_count']); $data['last_conversion'] = $this->conversion($data['last_likes_count'], $data['last_pi_count']); $data['conversion_delta'] = $this->delta($data['current_conversion'], $data['last_conversion']); return $data; }
protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); $user_values = $request->getParameter('user'); if ($form->isValid()) { $user = UserTable::getInstance()->find($user_values['id']); $user->first_name = $user_values['first_name']; $user->last_name = $user_values['last_name']; $user->email = $user_values['email']; $org_password = $user_values['password']; if (strlen($user_values['password']) != 32) { $user->password = md5($user_values['password']); } $user->Setting->theme = $user_values['settings']['theme']; $user->Setting->culture = $user_values['settings']['culture']; $user->Setting->reminder = array_key_exists('reminder', $user_values['settings']); $this->getUser()->setAttribute('theme', $user->Setting->theme); $user->save(); $this->getUser()->setFlash('saved.success', 1); $this->redirect('account/index'); } }
public function executeEdit(sfWebRequest $request) { $account_id = $this->getUser()->getAttribute('account_id'); $this->roles = RoleTable::getInstance()->findByAccountId($account_id); $this->users = UserTable::getInstance()->findByAccountId($account_id); $account_id = $this->getUser()->getAttribute('account_id'); $this->forward404Unless($project = Doctrine::getTable('Project')->find(array($request->getParameter('id'))), sprintf('Object project does not exist (%s).', $request->getParameter('id'))); $this->form = new ProjectForm($project); $this->project_user = $project->AssignedUser; }