public function getPhotos($memberId = null)
 {
     if (is_null($memberId)) {
         throw new Exception('Member Id cannot be null.');
     } else {
         $result = PhotoTable::getInstance()->getPhotos($memberId);
         return $result;
     }
 }
Example #2
0
 public function executePreview()
 {
     $this->isStudent = $this->getUser()->isAuthenticated();
     $this->photos = PhotoTable::getInstance()->getPhotos($this->galery->getId(), $this->isStudent)->limit(4)->execute();
     $this->totalVisible = $this->galery->countPhotosVisible($this->isStudent);
     $this->totalPrivate = $this->galery->countPhotosVisible(True);
     $this->showMoreButton = $this->totalPrivate > count($this->photos);
     if ($this->showMoreButton) {
         $this->thumbsToDisplay = min(count($this->photos), 3);
     } else {
         $this->thumbsToDisplay = count($this->photos);
     }
 }
Example #3
0
 public function executeShow(sfWebRequest $request)
 {
     $this->galerie_photo = Doctrine_Core::getTable('GaleriePhoto')->find(array($request->getParameter('id')));
     // Hotlinking on a photo of the gallery
     $this->hotLinkedPhoto = intval($request->getParameter('photo'));
     $this->hotLinkedPass = preg_replace("/[^A-Za-z0-9 ]/", '', $request->getParameter('pass'));
     $this->isStudent = $this->getUser()->isAuthenticated();
     $this->isPhotographer = $this->galerie_photo->userIsPhotographer($this->getUser());
     $this->user = $this->getUser();
     // User auth changes photos we grab
     $this->photos = PhotoTable::getInstance()->getPhotos($this->galerie_photo->getId(), $this->isStudent, $this->hotLinkedPass)->execute();
     $response = $this->getResponse();
     $this->getContext()->getConfiguration()->loadHelpers('Thumb');
     $response->addMeta('og:title', $this->galerie_photo->getTitle());
     $response->addMeta('og:type', 'Galery');
     $response->addMeta('og:url', $this->generateUrl('galerie_photo_show', $this->galerie_photo));
     $response->addMeta('og:site_name', 'BDE-UTC : Portail des associations');
     $this->forward404Unless($this->galerie_photo);
 }
 function buildPhotos($completedid)
 {
     require_once PATH_CORE . '/classes/photo.class.php';
     // slight hack, assumes only one photo/video per challenge, as per our current spec, even though the schema allows more
     $photoTable = new PhotoTable($this->db);
     $photo = $photoTable->getRowObject();
     $photoids = $photoTable->getPhotosForCompletedChallenge($completedid);
     foreach ($photoids as $id) {
         if ($photo->load($id)) {
             $code .= '<img src="' . URL_SUBMITTED_IMAGES . '/' . $photo->localFilename . '" width="150" />';
         }
     }
     return $code;
 }
Example #5
0
 public function countPhotosVisible($logged_in = False)
 {
     return PhotoTable::getInstance()->getPhotos($this->getId(), $logged_in)->count();
 }
$manageObj->addColumn("fbSessions", "fb_sig_expires", "DATETIME");
$manageObj->addColumn("fbSessions", "fb_sig_profile_update_time", "DATETIME");
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'prizes.class.php')) {
    require_once PATH_CORE . '/classes/prizes.class.php';
    PrizeTable::createTable($manageObj);
    $prizeTable = new PrizeTable($manageObj->db);
}
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'video.class.php')) {
    // create video table
    require_once PATH_CORE . '/classes/video.class.php';
    VideoTable::createTable($manageObj);
}
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'photo.class.php')) {
    // create photo table
    require_once PATH_CORE . '/classes/photo.class.php';
    PhotoTable::createTable($manageObj);
}
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'challenges.class.php')) {
    require_once PATH_CORE . '/classes/challenges.class.php';
    ChallengeTable::createTable($manageObj);
    ChallengeCompletedTable::createTable($manageObj);
    $challengeTable = new ChallengeTable($manageObj->db);
    $challengeTable->populateCommonChallenges();
}
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'scores.class.php')) {
    require_once PATH_CORE . '/classes/scores.class.php';
    WeeklyScoresTable::createTable($manageObj);
}
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'contactEmails.class.php')) {
    // Create ContactEmail table for the contact us functions
    require_once PATH_CORE . '/classes/contactEmails.class.php';
 static function processChallengeSubmit(&$code, &$passback)
 {
     //$debug = $_POST['debugSubmit']; // NEVER TURN ON FOR LIVE SITE
     echo '<h2>Processing, please wait...</h2>';
     if ($debug) {
         echo "POST<pre>" . print_r($_POST, true) . "</pre>";
     }
     // TODO: grab session keys from post, validate session
     $passback .= "&text={$_POST['text']}";
     $passback .= "&embedCode={$_POST['embedCode']}";
     if ($debug) {
         echo $passback;
     }
     if (isset($_POST['challengeid']) && $_POST['challengeid']) {
         $challengeid = $_POST['challengeid'];
     } else {
         $code = "There was no challenge id present in your submission";
         return false;
     }
     if (isset($_POST['text'])) {
         $evidence = $_POST['text'];
     } else {
         $evidence = '';
         /*$code = "Your text submission was empty."; return false;*/
     }
     if (isset($_POST['userid']) && $_POST['userid']) {
         $userid = $_POST['userid'];
     } else {
         $code = 'Either you aren\'t a registered user or your session is expired. Please return to the home page or sign in to facebook again.';
         return false;
     }
     require_once PATH_CORE . '/classes/db.class.php';
     $db = new cloudDatabase();
     // create a CompletedChallenges object
     //$userid = $this->page->session->userid;
     /*	if (!$userid)
     		{
     			echo "<pre>" . print_r($this->page->session, true) . "</pre>";	
     			
     			return "Could not get userid from session."; 
     		}*/
     require_once PATH_CORE . '/classes/user.class.php';
     require_once PATH_CORE . '/classes/challenges.class.php';
     $challengeTable = new ChallengeTable($db);
     $userTable = new UserTable($db);
     $userInfoTable = new UserInfoTable($db);
     $completedTable = new ChallengeCompletedTable($db);
     $user = $userTable->getRowObject();
     $userInfo = $userInfoTable->getRowObject();
     $challenge = $challengeTable->getRowObject();
     $completed = $completedTable->getRowObject();
     dbRowObject::$debug = $debug;
     $user->load($userid);
     $userInfo->load($userid);
     $challenge->load($challengeid);
     // validate challenge submission info
     // validate eligibility, date, membership
     if ($challenge->remainingCompletions <= 0 && $challenge->initialCompletions > 0) {
         $code = 'This challenge can no longer be completed for credit.';
         return false;
     }
     if (!ChallengeTable::userIsEligible($challenge->eligibility, $user->eligibility)) {
         $code = 'We\'re sorry, you are not eligible to receive credit for this challenge.';
         return false;
     }
     if (preg_match("/text/i", $challenge->requires) && !($evidence != '')) {
         $code = 'Sorry, you need to convince us you actually did this!';
         return false;
     }
     //if () //  TODO: now is between date start and end
     $now = time();
     $dateStart = strtotime($challenge->dateStart);
     $dateEnd = strtotime($challenge->dateEnd);
     if ($now > $dateEnd) {
         $code = 'Sorry, you are too late to receive credit for this challenge!';
         return false;
     }
     if ($now < $dateStart) {
         $code = 'Sorry, you can\'t receive credit for this challenge yet -- try again later!';
         return false;
     }
     // if () TODO: check user maximum by querying order histor
     // more...
     // everythings ok:
     $challenge->remainingCompletions--;
     $completed->userid = $user->userid;
     $completed->challengeid = $challenge->id;
     $phpnow = time();
     $completed->dateSubmitted = date('Y-m-d H:i:s', $phpnow);
     $completed->status = 'submitted';
     $completed->evidence = $evidence;
     $completed->comments = $evidence;
     // editors will review these later
     /*
      * The following code is a bit tricky. There are two things going on. The first is that photos
      * or videos are being checked for and their records are being created, but we have 
      * tentatively created a CompleteChallenge record first so they can back-reference it
      * 
      * If a required photo or video turns out not to have appeared, we have to then return an error 
      * and delete the CC record.
      * 
      * An extra wrinkle is that if both video and photo are in the requires field, we can accept 
      * one or the other.
      * 
      */
     // Create the completed to attach to the media records...
     if (!$completed->insert()) {
         $code = 'Internal error submitting your evidence, please try again.';
         return false;
     }
     if (preg_match("/photo/i", $challenge->requires) || preg_match("/optionalphoto/i", $challenge->requires)) {
         if ($photoFilename = self::processChallengeSubmitPhoto($userid, $completed->id)) {
             if (!preg_match("/\\.(jpg|png|gif|jpeg?)\$/i", $photoFilename)) {
                 $msg = 'Sorry, your photo did not appear to be of type jpg, png, or gif.';
                 $error = true;
             } else {
                 // create photo in our db
                 require_once PATH_CORE . '/classes/photo.class.php';
                 $photoTable = new PhotoTable($db);
                 $photoTable->createPhotoForCompletedChallenge($userid, $completed->id, $photoFilename, 'Photo submitted for ' . $challenge->title);
                 $photoSubmitted = true;
                 // indicate that a photo was found
             }
         } else {
             if (!preg_match("/optionalphoto/i", $challenge->requires)) {
                 $msg = 'No photo submitted';
                 $error = true;
             }
         }
     }
     //$passback .= "&photo1={$photoFilename}"; // wont be correct filename, actually quite complicated to make this work properly
     //echo $passback;
     if (preg_match("/video/i", $challenge->requires)) {
         if ($videoEmbedCode = self::processChallengeSubmitVideo($userid, $completed->id)) {
             // create photo in our db
             require_once PATH_CORE . '/classes/video.class.php';
             $videoTable = new VideoTable($db);
             $videoTable->createVideoForCompletedChallenge($userid, $completed->id, $videoEmbedCode, 'Video submitted for ' . $challenge->title);
             $videoSubmitted = true;
             // indicate video found
         } else {
             $msg = 'You must enter a YouTube video url.';
             $error = true;
         }
     }
     // HACK: now handle the case where both photo and video boxes appeared, and only one was entered
     if ($photoSubmitted or $videoSubmitted) {
         $error = false;
     }
     // set the $error flag set by the other one to false if one of them was sucessfully created
     if ($error) {
         $completed->delete();
         // delete the temporary CC record
         $code = $msg;
         return false;
     }
     $challenge->update();
     require_once PATH_CORE . '/classes/template.class.php';
     $code .= 'We have received your submission for the challenge <b>' . $challenge->title . '</b>  (reference number #' . $completed->id . ')';
     dbRowObject::$debug = 0;
     // NEVER TURN ON FOR LIVE SITE
     // for testing purposes -- approve free points right away
     if ($challenge->shortName == 'testPoints10k') {
         $code2 = '';
         if (!$completedTable->approveChallenge($completed->id, $challenge->pointValue, &$code2, false)) {
             $code = $code2;
             return false;
         } else {
             $code = 'Free points awarded!';
         }
     }
     return true;
 }