예제 #1
0
function Ach_UploadVerification($destName, $tempPath, &$error)
{
    if (Ach_isBadgeImage($destName, true)) {
        $error = wfMsgExt('achievements-upload-not-allowed', array('parse'));
        return false;
    }
    return true;
}
 /**
  * Get list of recently uploaded files (RT #79288)
  *
  * @param $limit
  *
  * @return Title[]
  */
 public static function getRecentlyUploaded($limit)
 {
     global $wgEnableAchievementsExt;
     wfProfileIn(__METHOD__);
     $images = false;
     // get list of recent log entries (type = 'upload')
     // limit*2 because of possible duplicates in log caused by image reuploads
     $res = ApiService::call(array('action' => 'query', 'list' => 'logevents', 'letype' => 'upload', 'leprop' => 'title', 'lelimit' => $limit * 2));
     if (!empty($res['query']['logevents'])) {
         foreach ($res['query']['logevents'] as $entry) {
             // ignore Video:foo entries from VideoEmbedTool
             if ($entry['ns'] == NS_IMAGE && !WikiaFileHelper::isTitleVideo($entry['title'])) {
                 $image = Title::newFromText($entry['title']);
                 if (!empty($image)) {
                     // skip badges upload (RT #90607)
                     if (!empty($wgEnableAchievementsExt) && Ach_isBadgeImage($image->getText())) {
                         continue;
                     }
                     // use keys to remove duplicates
                     $images[$image->getDBkey()] = $image;
                     // limit number of results
                     if (count($images) == $limit) {
                         break;
                     }
                 }
             }
         }
         // use numeric keys
         if (is_array($images)) {
             $images = array_values($images);
         }
     }
     wfProfileOut(__METHOD__);
     return $images;
 }