public static function adjudicateProject($projectId, $offerId)
 {
     $userFields = array(User::PROFILE_DIRECTION, User::PROFILE_MOVIL, User::PROFILE_CITY);
     //Load proyect and offer
     $project = Project::loadById($projectId);
     $projectOwner = User::getUserInfo($project->user_id, $userFields);
     if (Project::canBeAdjudicated($project)) {
         $offer = Offer::getOffer($offerId);
         $winner = User::getUserInfo($offer->user_id, $userFields);
         //Set project as adjudicated
         $data = array('pro_status' => Project::PROJECT_STATUS_ADJUDICATED, 'pro_date_end' => date('Y-m-d H:i:s', time()));
         Project::updateProject($project->pro_id, $data);
         //Set offer as winner
         $data = array('awarded' => Offer::STATUS_AWARDED);
         Offer::updateOffer($offer->id, $data);
         //Send notificacions and emails
         self::notifyWinner($project, $projectOwner, $winner);
         // Send email to winner
         self::emailWinner($offer, $winner, $project, $projectOwner);
         // Send email to project owner
         self::emailProjectOwner($offer, $winner, $project, $projectOwner);
         // Notifiy other photographers about denied offers. Losers :D
         self::notifyLosers($project);
         //Track event in analytics
         // Event = Proyectos adjudicados
         $eventData = new \stdClass();
         $eventData->user_id = $projectOwner['id'];
         $eventData->photograph_id = $winner['id'];
         $eventData->project_name = $project->pro_tit;
         $events = FAnalytics::getInstance();
         $events->trackEvent('Proyecto', 'Proyectos adjudicados', json_encode($eventData));
     } else {
         //TODO Oh oh... strong notification here about this fail
         return false;
     }
     return true;
 }
Exemple #2
0
 $login = login($user_user, $user_pass);
 if ($login == false) {
     $app->addError("La combinación de Correo y Contraseña son incorrectos.");
     $app->getInput()->save();
     $app->redirect($app->getHelper('UrlHelper')->getUrl('login'));
     /* Mientras esto se mueve a donde debe estar */
     $app->shutdown();
     die;
     //$error = "La combinación de Correo y Contraseña son incorrectos.";
     //$actError = '$("#formError").slideDown("slow");
     //$actError = '$("#formError").css("display", "")';
 } else {
     // TODO: SACAR ESTA LOGICA DE AQUI JUNTO CON EL REFACTOR DE LOGIN
     if ($app->getRequest()->cookie('guest_project')) {
         // TODO: CAMBIAR ESTE QUERY CUANDO SE CAMBIE EL LOGIN, AHORA ES NECESARIO PORQ EN ESTE PUNTO LA COOKIE AUN NO EXISTE (MISMO REQUERT QUE CUANDO SE CREA Y NO SIRVE getCurrentUser())
         $currentUser = User::getUserByEmail($user_user);
         if ($currentUser->user_type == User::USER_TYPE_CLIENT) {
             $tmpProjectId = $app->getRequest()->cookie('guest_project');
             $tmpProject = TmpProject::getTmpProjectByTmpId($tmpProjectId);
             if ($tmpProject) {
                 $project = Project::createProjectFromTmp($tmpProject, $currentUser->id);
                 TmpProject::assignTmpProjectToUser($tmpProject->pro_id, $currentUser->id);
                 // Event: Proyectos subidos
                 $eventData = new stdClass();
                 $eventData->user_id = $currentUser->id;
                 $eventData->project_id = $project->id();
                 $eventData->project_name = $project->get('pro_tit');
                 $events = FAnalytics::getInstance();
                 $events->trackEvent('Proyecto', 'Proyectos subidos', json_encode($eventData));
             }
             // Delete cookie
Exemple #3
0
     $data = array('new_email' => null, 'new_email_code' => null);
     $user = User::updateUser($userId, $data);
     $response = new stdClass();
     if ($user) {
         $response->status = 'success';
     } else {
         $response->status = 'error';
     }
     echo json_encode($response);
     die;
 }
 // New email confirmation
 if ($action == 'new_email_confirmation') {
     $actCode = $app->getRequest()->get('act_code');
     $newEmailCode = $app->getRequest()->get('new_email_code');
     $user = User::getUserToConfirmNewEmail($actCode, $newEmailCode);
     if (!$user) {
         $app->addError("Ha ocurrido un error intentando confirmar un cambio de correo electrónico.");
     } else {
         $user->user = $user->new_email;
         $user->new_email = null;
         $user->new_email_code = null;
         $user->save();
         $app->addMessage("Tu correo electrónico ha sido cambiado exitosamente. Tu nueva cuenta de correo electrónico es <b>" . $user->user . "</b>");
     }
     $app->redirect(UrlHelper::getUrl('editarPerfil'));
     return;
 }
 //marcar notificaciones como leidas
 if ($action == "notificationAct") {
     $id = intval($_REQUEST['id']);