コード例 #1
0
 public function executeShow()
 {
     $userid = $this->getUser()->getAttribute('userid');
     $user = UserPeer::retrieveByPK($userid);
     $c = new Criteria();
     $c->add(AddressPeer::USER_ID, $user->getId());
     $c->add(AddressPeer::TYPE, 0);
     $this->addressh = AddressPeer::doSelectOne($c);
     $c->clear();
     $c->add(AddressPeer::USER_ID, $user->getId());
     $c->add(AddressPeer::TYPE, 1);
     $this->addressw = AddressPeer::doSelectOne($c);
     $c->clear();
     $c->add(AddressPeer::USER_ID, $user->getId());
     $c->add(AddressPeer::TYPE, 2);
     $this->addressp = AddressPeer::doSelectOne($c);
     $this->userid = $userid;
     //$this->address = AddressPeer::retrieveByPk($this->getRequestParameter('id'));
     //$this->forward404Unless($this->address);
     $c->clear();
     $c->add(UserchapterregionPeer::USER_ID, $userid);
     $this->ucrs = UserchapterregionPeer::doSelect($c);
     $regions = RegionPeer::doSelect(new Criteria());
     $regionlist = array();
     $regionlist[] = "Select a Region";
     foreach ($regions as $region) {
         $regionlist[$region->getId()] = $region->getName();
     }
     $this->regionlist = $regionlist;
 }
コード例 #2
0
ファイル: actions.class.php プロジェクト: rafd/SkuleCourses
 public function executeLogin(sfWebRequest $request)
 {
     if (helperFunctions::isLoggedIn($request)) {
         $this->redirect("siteadmin/index");
     }
     if ($request->isMethod(sfRequest::POST) && $request->hasParameter('username') && $request->hasParameter('password')) {
         $username = $request->getParameter("username");
         $password = $request->getParameter("password");
         if (helperFunctions::isMaliciousString($username) || helperFunctions::isMaliciousString($password)) {
             $this->error = "* Malicious keywords detected. Do not attempt this again!";
         } else {
             $conn = Propel::getConnection();
             $admin = UserPeer::retrieveByPK($username, $conn);
             if (!is_object($admin) || $admin->getPassword() != $password) {
                 $this->error = "* Incorrect credentials.";
             } elseif ($admin->getTypeId() != EnumItemPeer::USER_ADMIN) {
                 $this->error = "* You do not have enough clearance to access this section.";
             } else {
                 $this->getResponse()->setCookie('username', $username);
                 // redirect to whatever page the user came from
                 if ($request->hasParameter("redirect")) {
                     $redirect = $request->getParameter("redirect");
                 } else {
                     $redirect = "siteadmin/index";
                 }
                 $this->redirect($redirect);
             }
         }
     }
 }
コード例 #3
0
    public function executeChangepassword()
    {
        $oldpass = $this->getRequestParameter('oldpassword');
        $newpass = $this->getRequestParameter('newpassword');
        if ($oldpass) {
            $user = UserPeer::retrieveByPK($this->getUser()->getAttribute('userid'));
            $salt = md5(sfConfig::get('app_salt_password'));
            if (sha1($salt . $oldpass) == $user->getPassword()) {
                $user->setPassword($newpass);
                $user->save();
                $this->setFlash('changepassword', 'Password changed successfully.');
                $c = new Criteria();
                $c->add(PersonalPeer::USER_ID, $user->getId());
                $personal = PersonalPeer::doSelectOne($c);
                $name = $personal->getFirstname() . " " . $personal->getMiddlename() . " " . $personal->getLastname();
                $sendermail = sfConfig::get('app_from_mail');
                $sendername = sfConfig::get('app_from_name');
                $to = $personal->getEmail();
                $subject = "Password change request for ITBHU Global Org";
                $body = '
		
Dear ' . $name . ',

Someone, probably you have changed the password.
If its not you, please contact admin as soon as practical.

Admin,
ITBHU Global
';
                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body);
            } else {
                $this->setFlash('changepasswordErr', 'Incorrect Old Password');
            }
        }
    }
コード例 #4
0
ファイル: SiteUser.class.php プロジェクト: rayku/rayku
 /**
  * Returns logged person User object from database
  *
  * @return User
  */
 public function getRaykuUser()
 {
     if (is_null(self::$raykuUser)) {
         self::$raykuUser = UserPeer::retrieveByPK($this->getRaykuUserId());
     }
     return self::$raykuUser;
 }
コード例 #5
0
 protected function doClean($values)
 {
     if (is_null($values)) {
         $values = array();
     }
     if (!is_array($values)) {
         throw new InvalidArgumentException('You must pass an array parameter to the clean() method');
     }
     $duration = $values['duration'];
     if (is_null($duration)) {
         return $values;
     }
     $date = $values['date'];
     if (is_null($date)) {
         return $values;
     }
     $date = strtotime($date);
     $activity = ActivityPeer::retrieveByPK($values['Activity_id']);
     $roomId = isset($values['Room_id']) ? $values['Room_id'] : null;
     $reservation_id = isset($values['id']) ? $values['id'] : null;
     if (!is_null($activity)) {
         if (!is_null($values['User_id'])) {
             $user = UserPeer::retrieveByPK($values['User_id']);
             $subscriptions = $user->getActiveSubscriptions($date, $activity->getId(), $roomId);
         } else {
             if (!is_null($values['Card_id'])) {
                 $card = CardPeer::retrieveByPK($values['Card_id']);
                 $subscriptions = $card->getActiveSubscriptions($date, $activity->getId(), $roomId);
             } else {
                 /* Trick to enforce potential new login objects (Like User or Card) to update this function */
                 /* This way, the validator will always throw. */
                 $subscriptions = null;
             }
         }
         $valid = false;
         $maxAvailableDuration = 0;
         if (!empty($subscriptions)) {
             foreach ($subscriptions as $subscription) {
                 $remainingCredit = $subscription->getRemainingCredit($duration, $reservation_id);
                 if ($remainingCredit >= 0) {
                     $valid = true;
                     break;
                 } else {
                     if ($maxAvailableDuration < abs($remainingCredit)) {
                         /* We keep the maximum duration number for the reservation */
                         $maxAvailableDuration = abs($remainingCredit);
                     }
                 }
             }
         }
         if (!$valid) {
             $error = new sfValidatorError($this, 'invalid', array('remaining_credit' => $maxAvailableDuration));
             if ($this->getOption('throw_global_error')) {
                 throw $error;
             }
             throw new sfValidatorErrorSchema($this, array('duration' => $error));
         }
     }
     return $values;
 }
コード例 #6
0
 function getUserLink($userId = null)
 {
     if (is_null($userId)) {
         $userId = $this->getUserId();
     }
     sfProjectConfiguration::getActive()->loadHelpers(array('Tag', 'Url'));
     $user = UserPeer::retrieveByPK($userId);
     return !$user ? '<i>Deleted account</i>' : link_to($user->getUsername(), '@profile?username=' . $user->getUsername());
 }
コード例 #7
0
 protected function doClean($values)
 {
     if (is_null($values)) {
         $values = array();
     }
     if (!is_array($values)) {
         throw new InvalidArgumentException('You must pass an array parameter to the clean() method');
     }
     $duration = $values['duration'];
     if (is_null($duration)) {
         return $values;
     }
     $date = $values['date'];
     if (is_null($date)) {
         return $values;
     }
     $date = strtotime($date);
     $activity = ActivityPeer::retrieveByPK($values['Activity_id']);
     $roomId = isset($values['Room_id']) ? $values['Room_id'] : null;
     $reservation_id = isset($values['id']) ? $values['id'] : null;
     if (!is_null($activity)) {
         if (!is_null($values['User_id'])) {
             $user = UserPeer::retrieveByPK($values['User_id']);
             $hours_per_week = $user->getHoursPerWeek($activity->getId(), $roomId);
             $total = $user->countMinutesPerWeek($activity->getId(), $roomId, $date, $reservation_id);
         } else {
             if (!is_null($values['Card_id'])) {
                 $card = CardPeer::retrieveByPK($values['Card_id']);
                 $hours_per_week = $card->getHoursPerWeek($activity->getId(), $roomId);
                 $total = $card->countMinutesPerWeek($activity->getId(), $roomId, $date, $reservation_id);
             } else {
                 /* Trick to enforce potential new login objects (Like User or Card) to update this function */
                 /* This way, the validator will always throw. */
                 $hours_per_week = null;
                 $total = null;
             }
         }
         if (empty($total)) {
             $total = 0;
         }
         if ($hours_per_week < 0 || is_null($hours_per_week)) {
             $error = new sfValidatorError($this, 'no_hours_per_week', array());
             if ($this->getOption('throw_global_error')) {
                 throw $error;
             }
             throw new sfValidatorErrorSchema($this, array('duration' => $error));
         }
         if ($total + $duration > $hours_per_week * 60) {
             $error = new sfValidatorError($this, 'invalid', array('minutes_per_week' => $hours_per_week * 60, 'total' => $total));
             if ($this->getOption('throw_global_error')) {
                 throw $error;
             }
             throw new sfValidatorErrorSchema($this, array('duration' => $error));
         }
     }
     return $values;
 }
コード例 #8
0
 /**
  * Triggers a system event. 
  * 
  * This will create a SystemEventInstance instance and notify any remote 
  * systems if they have active SystemEventSubscription objects. 
  * 
  * Each subscriber will be sent a unique SystemEventInstanceMessage.
  * 
  * eg.
  * 
  *     $message = new stdClass();
  *     $message->user_id = 54;
  *     $message->city = 'Vancouver';
  *     \SystemEventPeer::triggerEvent( 'new_user_signed_up', $message );
  * 
  * 
  * 
  * @param string $event_unique_key
  * @param stdClass $message
  * @param integer $user_id
  * 
  * @throws \Exception if system event is not known
  * @throws \Exception if $message is not a stdClass (if not null)
  * @throws \Exception if $user_id is provided (not null) but not found
  * 
  * @return SystemEventInstance
  */
 public static function triggerEvent($event_unique_key, $message = null, $user_id = null)
 {
     //validate the arguments
     $system_event = \SystemEventPeer::retrieveByUniqueKey($event_unique_key);
     if (!$system_event) {
         throw new \Exception('Unknown System Event: ' . $event_unique_key);
     }
     if (!is_null($message)) {
         if (!$message instanceof \stdClass) {
             throw new \Exception('Message must be a stdClass.');
         }
     } else {
         $message = new \stdClass();
     }
     if (!is_null($user_id)) {
         $user = \UserPeer::retrieveByPK($user_id);
         if (!$user) {
             throw new \Exception('Unknown User.');
         }
     } else {
         $user = \sfContext::getInstance()->getUser()->getProfile();
         if (!$user) {
             throw new \Exception('User must be logged in or you must provide a user_id to triggerError()');
         }
         $user_id = $user->getId();
     }
     //record the event
     $system_event_instance = new \SystemEventInstance();
     $system_event_instance->setMessage(json_encode($message));
     if (isset($user)) {
         $system_event_instance->setUser($user);
     }
     $system_event_instance->setSystemEvent($system_event);
     $system_event_instance->save();
     //get the subscribers for this event
     $system_event_subscriptions = \SystemEventSubscriptionPeer::getSubscriptionsForEvent($system_event->getId(), $user_id);
     //notify each of the subscribers
     foreach ($system_event_subscriptions as $system_event_subscription) {
         $system_event_subscription->saveSystemEventNotification($system_event_instance);
     }
 }
コード例 #9
0
 /**
  * This method just returns the user instance that
  * corresponds to the given username.
  * 
  */
 public function &loadUserByUsername($username)
 {
     //get the user from the database
     $user = UserPeer::retrieveByPK($username);
     return $user;
 }
コード例 #10
0
 /**
  * Get the associated User object
  *
  * @param      Connection Optional Connection object.
  * @return     User The associated User object.
  * @throws     PropelException
  */
 public function getUser($con = null)
 {
     // include the related Peer class
     include_once 'src/model/whiteboard/om/BaseUserPeer.php';
     if ($this->aUser === null && $this->user_id !== null) {
         $this->aUser = UserPeer::retrieveByPK($this->user_id, $con);
         /* The following can be used instead of the line above to
         		   guarantee the related object contains a reference
         		   to this object, but this level of coupling
         		   may be undesirable in many circumstances.
         		   As it can lead to a db query with many results that may
         		   never be used.
         		   $obj = UserPeer::retrieveByPK($this->user_id, $con);
         		   $obj->addUsers($this);
         		 */
     }
     return $this->aUser;
 }
コード例 #11
0
 public function setUser( $userId )
 {
     $this->user = \UserPeer::retrieveByPK( $userId );
 }
コード例 #12
0
ファイル: _showThread.php プロジェクト: rayku/rayku
<?php 
if ($_SESSION['edit_error']) {
    unset($_SESSION['edit_error']);
    ?>

		<p style="font-size:14px;color:red;padding-top:15px;" align="center"><em>Your editing privilages for this post has expired, sorry!</em></p>

<?php 
}
?>
  <div class="box">
    <div class="top"></div>
    <div class="content">
<div class="userinfo">
        <?php 
$user = UserPeer::retrieveByPK($post->getPosterId());
?>
        <div class="avatar-holder" style="float:none !important;"> <?php 
echo avatar_tag_for_user($user);
?>
 </div>
        <div class="spacer"></div>

<?php 
$connection = RaykuCommon::getDatabaseConnection();
$query = mysql_query("select * from user_score where user_id=" . $user->getId(), $connection) or die(mysql_error());
$row = mysql_fetch_assoc($query);
?>

<?php 
if ($user->getType() == 5) {
コード例 #13
0
ファイル: _showForum.php プロジェクト: rayku/rayku
    if (count($_StickieId) > 0 && count($_Non_StickieId) > 0) {
        $threads = array_merge($_StickieId, $_Non_StickieId);
    } else {
        if (count($_StickieId) > 0 && count($_Non_StickieId) == 0) {
            $threads = $_StickieId;
        } else {
            if (count($_StickieId) == 0 && count($_Non_StickieId) > 0) {
                $threads = $_Non_StickieId;
            }
        }
    }
    foreach ($threads as $thread) {
        $_class = '';
        $thread = ThreadPeer::retrieveByPK($thread);
        $post = PostPeer::getFirstForThreadId($thread->getId());
        $user = UserPeer::retrieveByPK($thread->getPosterId());
        if (!empty($_StickieId)) {
            if (in_array($thread->getId(), $_StickieId)) {
                $_class = "background-color:#E6F8FF";
            }
        }
        ?>
      <div class="entry" style="<?php 
        echo $_class;
        ?>
">
        <div class="information" >
          <?php 
        echo link_to($thread, '@view_thread?thread_id=' . $thread->getId(), array('class' => 'threadttle'));
        ?>
          <div class="threadst">
コード例 #14
0
         }
     }
     if (!isset($vocabulary)) {
         if ($concept) {
             $vocabulary = $concept->getVocabulary();
         }
     }
     $tab = false;
     break;
 case 'user':
     $showBc = true;
     $showUserBc = true;
     if (!isset($user)) {
         $id = 'show' == $action && !$historydetail ? $sf_params->get('id') : $paramId;
         if ($id) {
             $user = UserPeer::retrieveByPK($id);
         }
     }
     if ($user) {
         $objectId = $user->getID();
     }
     break;
 case 'version':
     $showBc = true;
     $showVocabularyBc = true;
     $showVersionBc = true;
     if (!isset($vocabulary_has_version)) {
         $id = 'show' == $action ? $sf_params->get('id') : $paramId;
         if ($id) {
             $vocabulary_has_version = VocabularyHasVersionPeer::retrieveByPK($id);
         }
コード例 #15
0
 public function executeAssignrole()
 {
     $roleid = $this->getRequestParameter('role');
     $userid = $this->getRequestParameter('assignee');
     $user = UserPeer::retrieveByPK($userid);
     $c = new Criteria();
     $c->add(UserrolePeer::USER_ID, $userid);
     $c->add(UserrolePeer::ROLE_ID, $roleid);
     $userrole = UserrolePeer::doSelectOne($c);
     if ($userrole) {
         $this->setFlash('notice', 'This role is already assigned for <b>' . $user->getFullname() . '</b>');
         $this->redirect('/search/result');
     }
     $userrole = new Userrole();
     $userrole->setUserId($userid);
     $userrole->setRoleId($roleid);
     $userrole->save();
     $this->setFlash('notice', 'Role assigned successfully for <b>' . $user->getFullname() . '</b>');
     $this->redirect('/search/result');
 }
コード例 #16
0
ファイル: actions.class.php プロジェクト: hoydaa/hoydaa.org
 public function handleErrorChangeProfile()
 {
     $this->ready();
     $this->user = UserPeer::retrieveByPK($this->getContext()->getUser()->getSubscriberId());
     if (sizeof($this->user->getDevelopers()) > 0) {
         $this->developer = $this->user->getDevelopers();
         $this->developer = $this->developer[0];
     } else {
         $this->developer = null;
     }
     return sfView::SUCCESS;
 }
コード例 #17
0
 public function executeProfile()
 {
     $this->user = UserPeer::retrieveByPK($this->getRequestParameter('id'));
     $c = new Criteria();
     $c->add(UserbadgePeer::USER_ID, $this->getRequestParameter('id'));
     $ubadges = UserbadgePeer::doSelect($c);
     $i = 0;
     $badges = "";
     foreach ($ubadges as $ub) {
         if ($i) {
             $badges .= ", " . $ub->getBadge()->getName();
         } else {
             $badges .= $ub->getBadge()->getName();
         }
         $i++;
     }
     $this->badges = $badges;
     $c->clear();
     $c->add(NotesPeer::USER_ID, $this->getRequestParameter('id'));
     $this->notes = NotesPeer::doSelectOne($c);
 }
コード例 #18
0
ファイル: Post.php プロジェクト: rayku/rayku
 /**
  * Gets the User object referenced by the poster_id field.
  * 
  * @return User
  */
 public function getPoster()
 {
     return UserPeer::retrieveByPK($this->getPosterId());
 }
コード例 #19
0
ファイル: User.php プロジェクト: Ayaan123/alumnisangam
 public function getPrivacyenabledvalue($flag, $value, $thisid)
 {
     $visitorid = sfContext::getInstance()->getUser()->getAttribute('userid');
     $visitor = UserPeer::retrieveByPK($visitorid);
     $c = new Criteria();
     $c->add(UserrolePeer::USER_ID, $visitorid);
     $c->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_admin'));
     $isadmin = UserrolePeer::doSelectOne($c);
     if ($visitorid == $thisid || $isadmin) {
         return $value;
     } else {
         switch ($flag) {
             case 1:
                 return sfConfig::get('app_privacy_message');
                 break;
             case 2:
                 $c = new Criteria();
                 $c->add(UserPeer::ID, $thisid);
                 $c->addJoin(UserPeer::ID, UserfriendPeer::USER_ID);
                 $c->addJoin(UserfriendPeer::FRIEND_ID, FriendPeer::ID);
                 $c->add(FriendPeer::USER_ID, $visitorid);
                 $frienduser = UserPeer::doSelectOne($c);
                 if ($frienduser) {
                     return $value;
                 } else {
                     return sfConfig::get('app_privacy_message');
                 }
                 break;
             case 3:
                 if ($visitorid) {
                     return $value;
                 } else {
                     return sfConfig::get('app_privacy_message');
                 }
                 break;
             case 4:
                 return $value;
                 break;
             default:
                 return $value;
         }
     }
 }
コード例 #20
0
    public function executeLorsubmit()
    {
        $data = $this->getRequestParameter('lorvalue');
        $type = $this->getRequestParameter('type');
        $toid = $this->getRequestParameter('toid');
        $newmail = $data;
        $lorForUser = UserPeer::retrieveByPK($toid);
        $lorById = $this->getUser()->getAttribute('userid');
        if ($lorById) {
            $lorByUser = UserPeer::retrieveByPK($lorById);
            $fromName = $lorByUser->getFullname();
        } else {
            $fromName = "Guest";
        }
        $lorvalue = new Lorvalues();
        $lorvalue->setLorfieldsId(sfConfig::get('app_lor_' . $type));
        $lorvalue->setData($data);
        $lorvalue->setUserId($lorById);
        $lorvalue->setCreatedAt(time());
        $lorvalue->save();
        $loruser = new Loruser();
        $loruser->setLorvaluesId($lorvalue->getId());
        $loruser->setUserId($toid);
        $loruser->save();
        if ($type == 'email') {
            $mail = new sfMail();
            $mail->initialize();
            //$mail->addCc(sfConfig::get('app_to_adminmail'));
            if ($lorForUser->getEmail()) {
                $mail->addAddress($lorForUser->getEmail());
            }
            $sendermail = sfConfig::get('app_from_mail');
            $sendername = sfConfig::get('app_from_name');
            $to = $newmail;
            $subject = "Alert: Connect with your friends at " . sfConfig::get('app_names_org');
            $body = '
			
Hi ' . $lorForUser->getFullname() . ',
	
	' . $fromName . ' has told us that your email address is 
	actually ' . $newmail . '.  If so, we strongly encourage you to claim it 
	at ' . sfConfig::get('app_urls_claim') . ' so you can connect with your friends.
	
	Admin,
	ITBHU Global
	';
            $mail = myUtility::newsendmail($mail, $sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body);
        }
        $this->setFlash('notice', 'Your remark on ' . sfConfig::get('app_lortext_' . $type) . ' has been saved successfully.');
        $this->redirect('/search/profile?id=' . $toid);
    }
コード例 #21
0
ファイル: actions.class.php プロジェクト: rayku/rayku
 public function executeAnswer()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     if (empty($_REQUEST['id'])) {
         return;
     }
     $id = $_REQUEST['id'];
     $time = time() - 600;
     $query = mysql_query("select * from user_expert where id=" . $id . " and time >= '" . $time . "' and status != 7 ", $connection) or die("Error1" . mysql_error());
     if (mysql_num_rows($query) > 0) {
         $row = mysql_fetch_assoc($query);
         $x = new Criteria();
         $x->add(UserPeer::ID, $row['checked_id']);
         $testUser = UserPeer::doSelectOne($x);
         $this->getUser()->signIn($testUser);
         $asker = UserPeer::retrieveByPK($row['user_id']);
         $askerUsername = $asker->getUsername();
         $askerName = $asker->getName();
         $this->getResponse()->setCookie("check_nick", urlencode($askerName), time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("askerUsername", $askerUsername, time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("askerid", $row['user_id'], time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("expertid", $row['checked_id'], time() + 3600, '/', sfConfig::get('app_cookies_domain'));
         $this->getResponse()->setCookie("asker_que", urlencode($row['question']), time() + 600, "/", sfConfig::get('app_cookies_domain'));
         $userdetail = mysql_query("select * from user where id=" . $row['checked_id'] . " ", $connection) or die("Error2" . mysql_error());
         if (mysql_num_rows($userdetail) > 0) {
             $rowuser = mysql_fetch_assoc($userdetail);
             $name = str_replace(" ", "", $rowuser['name']);
             $this->getResponse()->setCookie("loginname", $name, time() + 3600, '/', sfConfig::get('app_cookies_domain'));
             mysql_query("update user_expert set status = 7 where user_id =" . $row['checked_id'], $connection) or die("Error5" . mysql_error());
             mysql_query("delete from user_expire_msg where userid=" . $row['checked_id'], $connection) or die("Error_Expire2" . mysql_error());
             $this->redirect("/");
         }
     }
 }
コード例 #22
0
 /**
  * Handles discard request action
  *
  * @param sfWebRequest $request Web request object
  */
 public function executeDiscardRequest($request)
 {
     $jotag = TagPeer::getFromField(TagPeer::JOTAG, $request->getParameter('jotag'));
     $this->jotag = $jotag;
     $this->forward404Unless($this->jotag && TagPeer::isValid($this->jotag) && $this->jotag->getUser()->getId() == $this->getUser()->getSubscriberId());
     // get user
     $user = UserPeer::retrieveByPK($request->getParameter('user'));
     $this->forward404Unless($user);
     // verify user
     $tauth = $jotag->getRequestByUser($user);
     $this->forward404Unless($tauth->getStatus() != TagAuthPeer::STATUS_NONE);
     if ($tauth->getStatus() == TagAuthPeer::STATUS_PENDING) {
         $this->setMessage("AUTH_DISCARDED", "SUCCESS");
     } else {
         $this->setMessage("AUTH_DELETED", "SUCCESS");
     }
     $tauth->delete();
     $this->redirect("@manage_auth_request?jotag=" . $this->jotag->getJotag());
 }
コード例 #23
0
ファイル: ratingAction.class.php プロジェクト: rayku/rayku
 public function execute($request)
 {
     $connection = RaykuCommon::getDatabaseConnection();
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     mysql_query("delete from popup_close where user_id=" . $logedUserId, $connection) or die(mysql_error());
     if (isset($_SERVER['HTTP_COOKIE'])) {
         $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
         foreach ($cookies as $cookie) {
             $parts = explode('=', $cookie);
             $name = trim($parts[0]);
             if ($name != "rayku_frontend" && $name != "ratingExpertId" && $name != "ratingUserId" && $name != "timer" && $name != "whiteboardChatId") {
                 $this->getResponse()->setCookie($name, "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             }
         }
     }
     if (!empty($_POST)) {
         if (empty($_POST["rating"])) {
             $this->redirect('/dashboard/rating');
         }
         if (empty($_COOKIE['ratingExpertId']) && empty($_COOKIE['ratingUserId'])) {
             $this->redirect('/dashboard');
         } else {
             if (!empty($_COOKIE['raykuCharge'])) {
                 $rate = $_COOKIE['raykuCharge'];
             } else {
                 $user = UserPeer::retrieveByPK($_COOKIE["ratingExpertId"]);
                 if ($user) {
                     $rate = $user->getRate();
                 } else {
                     $rate = 0;
                 }
             }
             $timer = explode(":", $_COOKIE["timer"]);
             $newTimer = ($timer[0] * 3600 + $timer[1] * 60) / 60;
             $raykuPercentage = $newTimer * $rate;
             $_chat_rating = $_POST["rating"];
             $date = date('Y-m-d H:i:s');
             $queryScore = mysql_query("select * from user_score where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
             $rowScore = mysql_fetch_assoc($queryScore);
             $queryAsker = mysql_query("select * from user where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
             $rowAsker = mysql_fetch_assoc($queryAsker);
             $queryExpert = mysql_query("select * from user where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
             $rowExpert = mysql_fetch_assoc($queryExpert);
             $queryKinkarso = mysql_query("select * from user where id=124", $connection) or die(mysql_error());
             $rowKinkarso = mysql_fetch_assoc($queryKinkarso);
             if ($_POST["rating"] == 1) {
                 $check1RatingScore = $rowScore['score'] - 20;
                 if ($check1RatingScore < 1) {
                     $newRatingScore = "1";
                 } else {
                     $newRatingScore = $rowScore['score'] - 20;
                 }
                 mysql_query("update user_score set score = " . $newRatingScore . " where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                 if ($rate != '0.00') {
                     $kinkarsoPoints = $rowKinkarso["points"] + $raykuPercentage;
                     mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
                 }
             } elseif ($_POST["rating"] == 2) {
                 $tiptutor = $_POST["tiptutor"];
                 $askerPoints = $rowAsker["points"] - $raykuPercentage;
                 mysql_query("update user set points = " . $askerPoints . " where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                 $expertPer = $raykuPercentage * 25 / 100;
                 $kinkarsoPer = $raykuPercentage * 75 / 100;
                 $expertPoints = $rowExpert["points"] + $expertPer + $tiptutor;
                 $kinkarsoPoints = $rowKinkarso["points"] + $kinkarsoPer;
                 mysql_query("update user set points = " . $expertPoints . " where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                 mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
             } elseif ($_POST["rating"] == 3) {
                 $tiptutor = $_POST["tiptutor"];
                 $_Score = 0;
                 if ($newTimer > 10) {
                     $_Score = 10;
                 } elseif ($newTimer <= 10 && $newTimer >= 2) {
                     $_Score = 4;
                 }
                 if ($rate == '0.00') {
                     $_Score = $_Score * 2;
                 }
                 $newRatingScore = $rowScore['score'] + $_Score;
                 mysql_query("update user_score  set score = " . $newRatingScore . " where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                 if ($rate != '0.00') {
                     $askerPoints = $rowAsker["points"] - $raykuPercentage;
                     mysql_query("update user set points = " . $askerPoints . " where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                     $expertPer = $raykuPercentage * 50 / 100;
                     $kinkarsoPer = $raykuPercentage * 50 / 100;
                     $expertPoints = $rowExpert["points"] + $expertPer + $tiptutor;
                     $kinkarsoPoints = $rowKinkarso["points"] + $kinkarsoPer;
                     mysql_query("update user set points = " . $expertPoints . " where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                     mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
                 }
             } elseif ($_POST["rating"] == 4) {
                 $tiptutor = $_POST["tiptutor"];
                 $_Score = 0;
                 if ($newTimer > 10) {
                     $_Score = 18;
                 } elseif ($newTimer <= 10 && $newTimer >= 2) {
                     $_Score = 7;
                 }
                 if ($rate == '0.00') {
                     $_Score = $_Score * 2;
                 }
                 $newRatingScore = $rowScore['score'] + $_Score;
                 mysql_query("update user_score  set score = " . $newRatingScore . " where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                 if ($rate != '0.00') {
                     $askerPoints = $rowAsker["points"] - $raykuPercentage;
                     mysql_query("update user set points = " . $askerPoints . " where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                     $expertPer = $raykuPercentage * 75 / 100;
                     //60;
                     $kinkarsoPer = $raykuPercentage * 25 / 100;
                     //40;
                     $expertPoints = $rowExpert["points"] + $expertPer + $tiptutor;
                     $kinkarsoPoints = $rowKinkarso["points"] + $kinkarsoPer;
                     mysql_query("update user set points = " . $expertPoints . " where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                     mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
                 }
             } elseif ($_POST["rating"] == 5) {
                 $tiptutor = $_POST["tiptutor"];
                 $ratingScore = !empty($rowScore['score']) ? $rowScore['score'] : 0;
                 if ($rate != '0.00') {
                     $askerPoints = $rowAsker["points"] - $raykuPercentage;
                     mysql_query("update user set points = " . $askerPoints . " where id=" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                     $expertPer = $raykuPercentage;
                     // 5 stars: 100% RP
                     $expertPoints = $rowExpert["points"] + $expertPer + $tiptutor;
                     $kinkarsoPoints = $rowKinkarso["points"] + $kinkarsoPer;
                     mysql_query("update user set points = " . $expertPoints . " where id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                     mysql_query("update user set points = " . $kinkarsoPoints . " where id=124", $connection) or die(mysql_error());
                 }
                 $_Score = 0;
                 if ($newTimer > 10) {
                     $_Score = 25;
                 } elseif ($newTimer <= 10 && $newTimer >= 2) {
                     $_Score = 10;
                 }
                 if ($rate == '0.00') {
                     $_Score = $_Score * 2;
                 }
                 $newRatingScore = $rowScore['score'] + $_Score;
                 mysql_query("update user_score  set score = " . $newRatingScore . " where user_id=" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
             }
             if (isset($_POST["checkbox"]) && !empty($_POST["checkbox"])) {
                 if (!empty($_COOKIE["ratingExpertId"]) && !empty($_COOKIE["ratingUserId"])) {
                     $query = mysql_query("select * from expert_subscribers where expert_id = " . $_COOKIE["ratingExpertId"] . " and user_id =" . $_COOKIE["ratingUserId"], $connection) or die(mysql_error());
                     if (mysql_num_rows($query) == 0) {
                         mysql_query("insert into expert_subscribers(expert_id, user_id) values('" . $_COOKIE["ratingExpertId"] . "', '" . $_COOKIE["ratingUserId"] . "')", $connection) or die(mysql_error());
                         $queryScore = mysql_query("select * from user_score where user_id =" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                         $rowScore = mysql_fetch_assoc($queryScore);
                         $newScore = '';
                         $newScore = $rowScore['score'] + 10;
                         mysql_query("update user_score set score = " . $newScore . " where user_id =" . $_COOKIE["ratingExpertId"], $connection) or die(mysql_error());
                     }
                 }
             }
             if (!empty($_COOKIE["whiteboardChatId"]) && !empty($_COOKIE["whiteboardChatId"])) {
                 $chatId = $_COOKIE["whiteboardChatId"];
                 $_SESSION["whiteboard_Chat_Id"] = $_COOKIE["whiteboardChatId"];
                 if (isset($_POST["chkIsPublic"]) && !empty($_POST["chkIsPublic"])) {
                     $criteria = new Criteria();
                     $criteria->add(WhiteboardChatPeer::ID, $chatId);
                     $chat = WhiteboardChatPeer::doSelectOne($criteria);
                     if ($chat) {
                         $chat->setIsPublic(true);
                         $chat->save();
                     }
                 }
                 $_comments = !empty($_POST['content']) ? $_POST['content'] : '';
                 $_chat_query = mysql_query("select * from whiteboard_chat where id=" . $chatId . "", $connection) or "Error In Select" . mysql_error();
                 if (mysql_num_rows($_chat_query) > 0) {
                     $_chat_row = mysql_fetch_assoc($_chat_query);
                     mysql_query("update whiteboard_chat set timer = '" . $newTimer . "', rating = " . $_chat_rating . ", amount=" . $raykuPercentage . ", comments = '" . $_comments . "' where id=" . $chatId . " ", $connection) or die(mysql_error());
                 }
             }
             $this->getResponse()->setCookie("timer", "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             $this->getResponse()->setCookie("whiteboardChatId", "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             $this->getResponse()->setCookie("ratingExpertId", "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             $this->getResponse()->setCookie("ratingUserId", "", time() - 3600, '/', sfConfig::get('app_cookies_domain'));
             $this->user = $this->getUser()->getRaykuUser();
             $this->userPoints = $this->user->getPoints();
             $this->userFirstCharge = $this->user->getFirstCharge();
             if ($this->userPoints < 0 && empty($this->userFirstCharge)) {
                 $datetime = strtotime($row->createdate);
                 $mysqldate = date("m/d/y g:i A", $datetime);
                 $this->user->setFirstCharge($mysqldate);
             }
             if ($_chat_rating == 1 || $_chat_rating == 2) {
                 $this->redirect('/dashboard/moneyback');
             }
             $this->redirect('/referrals?session=complete');
         }
     }
 }
コード例 #24
0
ファイル: answerAction.class.php プロジェクト: rayku/rayku
 private function getRaykuCharge($expertId)
 {
     $user = UserPeer::retrieveByPK($expertId);
     return $user->getRate();
 }
コード例 #25
0
 protected function doClean($values)
 {
     if (is_null($values)) {
         $values = array();
     }
     if (!is_array($values)) {
         throw new InvalidArgumentException('You must pass an array parameter to the clean() method');
     }
     $date = strtotime($values['date']);
     $now = time();
     if ($date < $now) {
         return $values;
     }
     $activity = ActivityPeer::retrieveByPK($values['Activity_id']);
     $roomId = isset($values['Room_id']) ? $values['Room_id'] : null;
     if (!is_null($activity)) {
         $overall_minimum_delay = $activity->getMinimumDelay();
         $overall_minimum_date = $activity->getMinimumDate($now);
         if (!is_null($values['User_id'])) {
             $user = UserPeer::retrieveByPK($values['User_id']);
             $minimum_delay = $user->getMinimumDelay($activity->getId(), $roomId);
             $minimum_date = $user->getMinimumDate($activity->getId(), $roomId, $now);
             $maximum_delay = $user->getMaximumDelay($activity->getId(), $roomId);
             $maximum_date = $user->getMaximumDate($activity->getId(), $roomId, $now);
             $has_subscription = $user->hasSubscription($activity->getId(), $roomId, $date);
         } else {
             if (!is_null($values['Card_id'])) {
                 $card = CardPeer::retrieveByPK($values['Card_id']);
                 $minimum_delay = $card->getMinimumDelay($activity->getId(), $roomId);
                 $minimum_date = $card->getMinimumDate($activity->getId(), $roomId, $now);
                 $maximum_delay = $card->getMaximumDelay($activity->getId(), $roomId);
                 $maximum_date = $card->getMaximumDate($activity->getId(), $roomId, $now);
                 $has_subscription = $card->hasSubscription($activity->getId(), $roomId, $date);
             } else {
                 /* Trick to enforce potential new login objects (Like User or Card) to update this function */
                 /* This way, the validator will always throw. */
                 $has_subscription = false;
                 $minimum_delay = null;
                 $maximum_delay = null;
             }
         }
         if (!$has_subscription) {
             $error = new sfValidatorError($this, 'no_subscription', array());
             if ($this->getOption('throw_global_error')) {
                 throw $error;
             }
             throw new sfValidatorErrorSchema($this, array('date' => $error));
         }
         if ($date < $overall_minimum_date) {
             $error = new sfValidatorError($this, 'minimum_delay', array('minimum_delay' => $overall_minimum_delay));
             if ($this->getOption('throw_global_error')) {
                 throw $error;
             }
             throw new sfValidatorErrorSchema($this, array('date' => $error));
         }
         if ($maximum_delay < 0 || is_null($maximum_delay)) {
             $error = new sfValidatorError($this, 'no_delay', array());
             if ($this->getOption('throw_global_error')) {
                 throw $error;
             }
             throw new sfValidatorErrorSchema($this, array('date' => $error));
         }
         if ($date >= $maximum_date) {
             $error = new sfValidatorError($this, 'maximum_delay', array('maximum_delay' => $maximum_delay));
             if ($this->getOption('throw_global_error')) {
                 throw $error;
             }
             throw new sfValidatorErrorSchema($this, array('date' => $error));
         }
     }
     return $values;
 }
コード例 #26
0
ファイル: User.php プロジェクト: rayku/rayku
 /**
  * Sends the number of points specified in $points to $userID
  *
  * @param int $userID
  * @param int $points
  * @return bool
  */
 public function sendPointsToUser($userID, $points)
 {
     //If the user is banned, they can't give points
     if ($this->getHidden()) {
         return false;
     }
     //Nice try... you can't send negative points or send points to yourself
     //or send more points than you've got or send a non-numeric number of
     //points
     if ($points < 1 || $userID == $this->getId() || $this->getPoints() < $points || !is_numeric($points)) {
         return false;
     }
     $user = UserPeer::retrieveByPK($userID);
     //If there's no such user, return false
     if (!$user) {
         return false;
     }
     //Move the points
     $user->setPoints($user->getPoints() + $points);
     $this->setPoints($this->getPoints() - $points);
     //If the transaction worked on both ends, return true
     return $user->save() && $this->save();
 }
コード例 #27
0
ファイル: actions.class.php プロジェクト: rayku/rayku
    public function executeExpertReplyThread()
    {
        $connection = RaykuCommon::getDatabaseConnection();
        $c = new Criteria();
        $c->add(ForumPeer::TYPE, 0);
        $this->publicforums = ForumPeer::doSelect($c);
        $this->allcategories = CategoryPeer::doSelect($c = new Criteria());
        $this->forum = $this->getRequestParameter('forum_id');
        $this->thread = ThreadPeer::retrieveByPK($this->getRequestParameter('thread_id'));
        $c = new Criteria();
        $c->add(PostPeer::THREAD_ID, $this->thread->getId());
        $this->post = PostPeer::doSelectOne($c);
        $user = $this->getUser()->getRaykuUser();
        if ($this->getRequestParameter('post_edit_content') != '') {
            $threadId = $this->getRequestParameter('thread_id');
            $_thread = ThreadPeer::retrieveByPK($threadId);
            $_thread->setTitle($this->getRequestParameter('post_edit_title'));
            $_thread->save();
            $v = new Criteria();
            $v->add(PostPeer::THREAD_ID, $threadId);
            $v->addAscendingOrderByColumn(PostPeer::ID);
            $post = PostPeer::doSelectOne($v);
            $post->setContent($this->getRequestParameter('post_edit_content'));
            $post->save();
            return $this->redirect('@view_thread?thread_id=' . $threadId);
        }
        if ($this->getRequestParameter('post_body') != '') {
            if ($this->getRequestParameter('final_id') != '') {
                $_quick_reply = '';
                $_post_id = $this->getRequestParameter('final_id');
                $_Post = PostPeer::retrieveByPK($_post_id);
                $_User = UserPeer::retrieveByPK($_Post->getPosterId());
                $_quick_reply .= "<div style='margin-left:20px'><em><strong>Quote from " . $_User->getUsername() . "</strong></em><br><br>";
                $_explode_post = explode("*^-", $_Post->getContent());
                if (count($_explode_post) > 1) {
                    $_quick_reply .= $_explode_post[1];
                } else {
                    $_quick_reply .= $_Post->getContent();
                }
                $_quick_reply .= "</div>";
                $_post_body_msg = $this->getRequestParameter('post_body');
                $_quick_reply .= $_post_body_msg;
                $user->makeNewPost($this->getRequestParameter('thread_id'), $_quick_reply);
                ///////////////////updating the ip of the user
                $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection));
                mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection);
                ///////////////////updating the ip of the user
            } else {
                $user->makeNewPost($this->getRequestParameter('thread_id'), $this->getRequestParameter('post_body'));
                ///////////////////updating the ip of the user
                $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection));
                mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection);
                ///////////////////updating the ip of the user
            }
            if ($this->getUser()->getRaykuUser()->getType() == '5') {
                $c = new Criteria();
                $c->add(ThreadPeer::ID, $this->getRequestParameter('thread_id'));
                $thread = ThreadPeer::doSelectOne($c);
                $c = new Criteria();
                $c->add(UserPeer::ID, $thread->getPosterId());
                $user = UserPeer::doSelectOne($c);
                if ($thread->getNotifyPm() == '1') {
                    $subject = 'Expert Response for your Question';
                    $body = 'Hi there, <br><br>
							A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '" has just responsed to your question, "' . $thread->getTitle() . '" on the question boards. Take a look!<br><br>
							Rayku Administration';
                    //Grab the user object
                    $currentuser = UserPeer::retrieveByPK($this->getUser()->getRaykuUserId());
                    //Send the message
                    $currentuser->sendMessage($user->getId(), $subject, $body);
                }
                if ($thread->getNotifyEmail() == '1') {
                    $this->mail = new sfMail();
                    //Set the to, from, and subject headers
                    $this->mail->addAddress($user->getEmail());
                    $this->mail->setFrom('Expert <' . $this->getUser()->getRaykuUser()->getEmail() . '>');
                    $this->mail->setSubject('Expert Response to your Question');
                    $this->mail->setBody('Hi there,<br>
							A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '", has just responded to your question (below) on the question boards. Take a look!<br><br>
							' . $thread->getTitle() . '');
                    $this->mail->send();
                }
            }
            return $this->redirect('@view_thread?thread_id=' . $this->thread->getId());
        }
    }
コード例 #28
0
ファイル: indexSuccess.php プロジェクト: rayku/rayku
        </div>
    
    <!--followers begins-->
    <div id="followers">
      <h4><span class="foll-no">
        <?php 
echo $num_followers;
?>
        </span> Followers</h4>
      <div  id="followers-images">
<?php 
$logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
$query = mysql_query("select * from expert_subscribers as es, user as u where es.expert_id=" . $expert->getId() . " and es.user_id = u.id ", $connection) or die("error1");
if (mysql_num_rows($query) > 0) {
    while ($row = mysql_fetch_array($query)) {
        $_followers = UserPeer::retrieveByPK($row['user_id']);
        echo link_to(avatar_tag_for_user($_followers), '@tutor?username=' . $_followers->getUsername());
    }
}
?>
      </div>
      <!--followers images ends-->
    </div>
    <!--followers ends-->
  </div>
  <!--content ends-->
  <!--sidebar-begins-->
  <div id="sidebar">
  
  
  <!-- FEATURE TO BE IMPLEMENTED
コード例 #29
0
 public function getUser($con = null)
 {
     include_once 'lib/model/om/BaseUserPeer.php';
     if ($this->aUser === null && $this->user_id !== null) {
         $this->aUser = UserPeer::retrieveByPK($this->user_id, $con);
     }
     return $this->aUser;
 }
コード例 #30
0
ファイル: actions.class.php プロジェクト: rayku/rayku
 public function executeShowAvatar()
 {
     $user = UserPeer::retrieveByPK($this->getRequestParameter('user_id'));
     $this->forward404Unless($user instanceof User);
     $allowedSizes = array(1, 2, 3, 4);
     if (!in_array($this->getRequestParameter('size'), $allowedSizes)) {
         $size = 1;
     } else {
         $size = $this->getRequestParameter('size');
     }
     switch ($size) {
         case 1:
             $fileSuffix = '';
             break;
         default:
             $fileSuffix = "_{$size}";
             break;
     }
     $uploadDir = sfConfig::get('sf_upload_dir') . DIRECTORY_SEPARATOR . sfConfig::get('app_general_avatar_folder');
     $file = $uploadDir . DIRECTORY_SEPARATOR . $user->getId() . $fileSuffix;
     if (!is_file($file)) {
         $file = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . sfConfig::get('app_general_avatar_default_image') . $fileSuffix . '.' . sfConfig::get('app_general_avatar_default_image_type');
     }
     $this->getResponse()->clearHttpHeaders();
     $this->getResponse()->setHttpHeader('Content-Length', (string) filesize($file), true);
     $this->getResponse()->setHttpHeader('Content-Transfer-Encoding', 'binary', true);
     $this->getResponse()->setContentType('image/jpeg');
     $this->getResponse()->sendHttpHeaders();
     readfile($file);
     exit;
     // for some reason, this fixed some bugs with sfWebResponse trying to output again later (despite sfView::NONE returned)
     return sfView::NONE;
 }