示例#1
0
 /**
  * 
  * @param string $surname
  * @param string $error
  * @return boolean
  */
 public static function validateSurname($surname, &$error = NULL) {
     $len = strlen($surname);
     $cleaned = PCHelperInputCleaner::cleanInputString($surname);
     $lenOther = strlen($cleaned);
     if ($len != $lenOther) {
         $error = "Surname is not valid";
         return FALSE;
     }
     return TRUE;
 }
示例#2
0
 /**
  * Aggiunge una recensione
  * @param PCRequest $request
  */
 public function addReviewAction($request){
     
     $auth = $request->getAuthHandler();
     if($auth->isAuthorized() == FALSE){
         throw new PCExceptionAuth("Auth Required", 401);
     }
     
     
     $params = $request->getParams();
   
     $url =  PCHelperInputCleaner::cleanInputString($params['siteUrl']);
     $comment = PCHelperInputCleaner::cleanInputString($params['comment']);
     $contents = PCHelperInputCleaner::cleanInputString($params['contents']);
     $reliability = PCHelperInputCleaner::cleanInputString($params['reliability']);
     $usability = PCHelperInputCleaner::cleanInputString( $params['usability']);
     $category = PCHelperInputCleaner::cleanInputString($params['category']);
     $language = PCHelperInputCleaner::cleanInputString($params['language_code']);
     $siteIdentifier =  PCHelperInputCleaner::cleanInputString($params['site_identifier']);
     
     if((!empty($url) || !empty($siteIdentifier)) && isset($comment) && isset($contents) && isset($reliability) && isset($usability) && isset($category) && isset($language)){
         $error = NULL;
         $user = PCModelUser::getCurrentUser();
         $result = PCMapperWebsite::addSiteWithReview($url, $user, $comment, $usability, $contents, $reliability, $category, $language, $error, $siteIdentifier);
         if($result){
             if(PCConfigManager::sharedManager()->getBoolValue('SOCIAL_POST_ON_REVIEW')){
                 $userName = $user->getUsername();
                 PCHelperNotificationSender::sendPushNotificationToAdmin("Aggiunta Recensione", "User: $userName r($reliability) u($usability) c($contents) url: $url");
             }
             
             return new PCRendererJSON(array("OK"=>"Site Added"));
         }
         else{
             error_log($error);
             return new PCRendererJSON(array("error"=>$error),401);
         }
         
     }
     
     return new PCRendererJSON("Error adding site", 400);
     
 }