ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç db/access.php000064400000002241152266404430007110 0ustar00. /** * Plugin capabilities. * * @package repository_flickr_public * @copyright 2009 Dongsheng Cai * @author Dongsheng Cai * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $capabilities = array( 'repository/flickr_public:view' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, 'archetypes' => array( 'user' => CAP_ALLOW ) ) ); lang/en/repository_flickr_public.php000064400000006177152266404430013730 0ustar00. /** * Strings for component 'repository_flickr_public', language 'en', branch 'MOODLE_20_STABLE' * * @package repository_flickr_public * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $string['all'] = 'All'; $string['apikey'] = 'API key'; $string['backtosearch'] = 'Back to search screen'; $string['by'] = 'Attribution license'; $string['by-nc'] = 'Attribution-NonCommercial license'; $string['by-nc-nd'] = 'Attribution-NonCommercial-NoDerivs license'; $string['by-nc-sa'] = 'Attribution-NonCommercial-ShareAlike license'; $string['by-nd'] = 'Attribution-NoDerivs license'; $string['by-sa'] = 'Attribution-ShareAlike license'; $string['callbackurl'] = 'Callback URL'; $string['commercialuse'] = 'I want to use the images commercially'; $string['configplugin'] = 'Flickr public configuration'; $string['creativecommonscommercial'] = 'Only creative commons commercial'; $string['emailaddress'] = 'Email address'; $string['flickr_public:view'] = 'Use Flickr public repository in file picker'; $string['fulltext'] = 'Full text'; $string['information'] = '
Get a Flickr API Key for your Moodle site.
'; $string['invalidemail'] = 'Invalid email account for flickr'; $string['license'] = 'Licence'; $string['modification'] = 'I want to be able to modify the images'; $string['notitle'] = 'notitle'; $string['nullphotolist'] = 'There are no photos in this account'; $string['remember'] = 'Remember me'; $string['pluginname_help'] = 'Repository on flickr.com'; $string['pluginname'] = 'Flickr public'; $string['secret'] = 'Secret'; $string['sharealike'] = 'Yes, as long as others share alike'; $string['tag'] = 'Tag'; $string['username'] = 'Flickr account email'; $string['watermark'] = 'Add watermark to photos'; $string['privacy:metadata:repository_flickr_public'] = 'The Flickr public repository plugin does not store any personal data, but does transmit user data from Moodle to the remote system.'; $string['privacy:metadata:repository_flickr_public:author'] = 'The Flickr public repository content author.'; $string['privacy:metadata:repository_flickr_public:email_address'] = 'The Flickr public repository user email address.'; $string['privacy:metadata:repository_flickr_public:text'] = 'The Flickr public repository user search text.'; $string['privacy:metadata:repository_flickr_public:user_id'] = 'The Flickr public repository user ID.'; image.php000064400000011642152266404430006351 0ustar00. /** * moodle_image class * * @package repository * @subpackage flickr_public * @author Dongsheng Cai * @license http://www.gnu.org/copyleft/gpl.html GNU Public License */ class moodle_image { private $imagepath; private $info; private $width; private $height; private $image; private $backup; function __construct($img) { ini_set('gd.jpeg_ignore_warning', 1); if(!function_exists('imagecreatefrompng') and !function_exists('imagecreatefromjpeg')) { throw new moodle_exception('gdnotexist'); } if(!file_exists($img) or !is_readable($img)) { throw new moodle_exception('invalidfile'); } $this->imagepath = $img; unset($img); $this->info = getimagesize($this->imagepath); switch($this->info['mime']) { case 'image/jpeg': $this->image = imagecreatefromjpeg($this->imagepath); break; case 'image/png': $this->image = imagecreatefrompng($this->imagepath); break; case 'image/gif': $this->image = imagecreatefromgif($this->imagepath); break; default: break; } $this->width = imagesx($this->image); $this->height = imagesy($this->image); } function destroy() { imagedestroy($this->image); imagedestroy($this->backup); return true; } function undo() { $this->image = $this->backup; return $this; } function watermark($text='', $pos=array(), $options=array()) { global $CFG; $text = iconv('ISO-8859-8', 'UTF-8', $text); if (empty($options['fontsize'])) { if (!empty($options['ttf'])) { $options['fontsize'] = 12; } else { $options['fontsize'] = 1; } } if (empty($options['font'])) { $options['font'] = $CFG->libdir . '/default.ttf'; } if (empty($options['angle'])) { $options['angle'] = 0; } $clr = imagecolorallocate($this->image, 255, 255, 255); if (!empty($options['ttf'])) { imagettftext($this->image, $options['fontsize'], // font size $options['angle'], $pos[0], $pos[1]+$options['fontsize'], $clr, $options['font'], $text); } else { imagestring($this->image, $options['fontsize'], $pos[0], $pos[1], $text, $clr); } return $this; } function rotate($angle=0, $bgcolor=0) { $this->image = imagerotate($this->image, $angle, $bgcolor); return $this; } function resize($w, $h, $use_resize = true) { if(empty($h) && !empty($w)) { $h = $this->height * ($w/$this->width); } if(!empty($h) && empty($w)) { $w = $this->width * ($h/$this->height); } $new_img = imagecreatetruecolor($w, $h); imagealphablending($new_img, false); imagecopyresampled($new_img /* dst */, $this->image /* src */, 0, 0, 0, 0, $w, $h, $this->width, $this->height); $this->image = $new_img; return $this; } function saveas($imagepath) { switch($this->info['mime']) { case 'image/jpeg': return imagejpeg($this->image, $imagepath); break; case 'image/png': return imagepng($this->image, $imagepath); break; case 'image/gif': return imagegif($this->image, $imagepath); break; default: break; } if(!$this->destroy()) { return false; } else { return $this; } } function display() { header('Content-type: '.$this->info['mime']); switch($this->info['mime']) { case 'image/png': imagepng($this->image); break; case 'image/jpeg': imagejpeg($this->image); break; case 'image/gif': imagegif($this->image); break; default: break; } $this->destroy(); return $this; } } pix/icon.png000064400000001574152266404430007017 0ustar00PNG  IHDR(-SPLTE̵ʷPUacdkkl,|/6QsssttC3quxy*,O]UMtRNS#$,:;>GJJLSTVabdellrxy~.\IDATx5AQEuܝp*hpHw[DW%bAաa3/cc ~۸~dB4yPGO\jOݓl}T$ԔiŸxkU $QqQ.x tBy 7k9{]ڇ tܱ#!@O9׽s,"@x"Aב} cx k"_]z EJIENDB`lib.php000064400000052353152266404430006041 0ustar00. /** * This plugin is used to access flickr pictures * * @since Moodle 2.0 * @package repository_flickr_public * @copyright 2010 Dongsheng Cai {@link http://dongsheng.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot . '/repository/lib.php'); require_once($CFG->libdir.'/flickrlib.php'); require_once(__DIR__ . '/image.php'); /** * repository_flickr_public class * This one is used to create public repository * You can set up a public account in admin page, so everyone can access * flickr photos from this plugin * * @since Moodle 2.0 * @package repository_flickr_public * @copyright 2009 Dongsheng Cai {@link http://dongsheng.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class repository_flickr_public extends repository { /** @var phpFlickr Flickr class. */ private $flickr; /** @var string Flick photos. */ public $photos; /** @var string API key. */ protected $api_key; /** @var string email address account. */ protected $flickr_account; /** @var string watermarks usage status. */ protected $usewatermarks; /** @var string session account. */ protected $sess_account; /** @var string session tag. */ protected $sess_tag; /** @var string session text. */ protected $sess_text; /** @var string Flickr user identifier. */ protected $nsid; /** * Stores sizes of images to prevent multiple API call */ static private $sizes = array(); /** * constructor method * * @global object $CFG * @global object $SESSION * @param int $repositoryid * @param int $context * @param array $options * @param boolean $readonly */ public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array(), $readonly=0) { global $CFG, $SESSION; parent::__construct($repositoryid, $context, $options,$readonly); $this->api_key = $this->get_option('api_key'); $this->flickr = new phpFlickr($this->api_key); $this->flickr_account = $this->get_option('email_address'); $this->usewatermarks = $this->get_option('usewatermarks'); $account = optional_param('flickr_account', '', PARAM_RAW); $fulltext = optional_param('flickr_fulltext', '', PARAM_RAW); if (empty($fulltext)) { $fulltext = optional_param('s', '', PARAM_RAW); } $tag = optional_param('flickr_tag', '', PARAM_RAW); $license = optional_param('flickr_license', '', PARAM_RAW); $this->sess_account = 'flickr_public_'.$this->id.'_account'; $this->sess_tag = 'flickr_public_'.$this->id.'_tag'; $this->sess_text = 'flickr_public_'.$this->id.'_text'; if (!empty($account) or !empty($fulltext) or !empty($tag) or !empty($license)) { $SESSION->{$this->sess_tag} = $tag; $SESSION->{$this->sess_text} = $fulltext; $SESSION->{$this->sess_account} = $account; } } /** * save api_key in config table * @param array $options * @return boolean */ public function set_option($options = array()) { if (!empty($options['api_key'])) { set_config('api_key', trim($options['api_key']), 'flickr_public'); } unset($options['api_key']); return parent::set_option($options); } /** * get api_key from config table * * @param string $config * @return mixed */ public function get_option($config = '') { if ($config==='api_key') { return trim(get_config('flickr_public', 'api_key')); } else { $options['api_key'] = trim(get_config('flickr_public', 'api_key')); } return parent::get_option($config); } /** * is global_search available? * * @return boolean */ public function global_search() { if (empty($this->flickr_account)) { return false; } else { return true; } } /** * check if flickr account * @return boolean */ public function check_login() { return !empty($this->flickr_account); } /** * construct login form * * @param boolean $ajax * @return array */ public function print_login() { if ($this->options['ajax']) { $ret = array(); $fulltext = new stdClass(); $fulltext->label = get_string('fulltext', 'repository_flickr_public').': '; $fulltext->id = 'el_fulltext'; $fulltext->type = 'text'; $fulltext->name = 'flickr_fulltext'; $tag = new stdClass(); $tag->label = get_string('tag', 'repository_flickr_public').': '; $tag->id = 'el_tag'; $tag->type = 'text'; $tag->name = 'flickr_tag'; $email_field = new stdClass(); $email_field->label = get_string('username', 'repository_flickr_public').': '; $email_field->id = 'account'; $email_field->type = 'text'; $email_field->name = 'flickr_account'; $commercial = new stdClass(); $commercial->label = get_string('commercialuse', 'repository_flickr_public').': '; $commercial->id = 'flickr_commercial_id'; $commercial->type = 'checkbox'; $commercial->name = 'flickr_commercial'; $commercial->value = 'yes'; $modification = new stdClass(); $modification->label = get_string('modification', 'repository_flickr_public').': '; $modification->id = 'flickr_modification_id'; $modification->type = 'checkbox'; $modification->name = 'flickr_modification'; $modification->value = 'yes'; $ret['login'] = array($fulltext, $tag, $email_field, $commercial, $modification); $ret['login_btn_label'] = get_string('search'); $ret['login_btn_action'] = 'search'; return $ret; } else { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo ''; } } /** * destroy session * * @return object */ public function logout() { global $SESSION; unset($SESSION->{$this->sess_tag}); unset($SESSION->{$this->sess_text}); unset($SESSION->{$this->sess_account}); return $this->print_login(); } public function license4moodle($license_id) { $license = array( '0' => 'allrightsreserved', '1' => 'cc-nc-sa', '2' => 'cc-nc', '3' => 'cc-nc-nd', '4' => 'cc', '5' => 'cc-sa', '6' => 'cc-nd', '7' => 'other' ); return $license[$license_id]; } /** * search images on flickr * * @param string $search_text * @return array */ public function search($search_text, $page = 0) { global $SESSION; $ret = array(); if (empty($page)) { $page = 1; } if (!empty($this->flickr_account)) { $people = $this->flickr->people_findByEmail($this->flickr_account); $this->nsid = $people['nsid']; } if (!empty($SESSION->{$this->sess_account})) { $people = $this->flickr->people_findByEmail($SESSION->{$this->sess_account}); $this->nsid = $people['nsid']; } if (empty($this->nsid)) { $this->nsid = null; // user specify a flickr account, but it is not valid if (!empty($this->flickr_account) or !empty($SESSION->{$this->sess_account})) { $ret['e'] = get_string('invalidemail', 'repository_flickr_public'); return $ret; } } // including all licenses by default $licenses = array(1=>1, 2, 3, 4, 5, 6, 7); $commercial = optional_param('flickr_commercial', '', PARAM_RAW); $modification = optional_param('flickr_modification', '', PARAM_RAW); if ($commercial == 'yes') { // including // 4: Attribution License // 5: Attribution ShareAlike // 6: Attribution NoDerives // 7: unknown license unset($licenses[1], $licenses[2], $licenses[3]); } if ($modification == 'yes') { // including // 1: Attribution NonCommercial ShareAlike // 2: Attribution NonCommercial // 4: Attribution License // 5: Attribution ShareAlike // 7: unknown license unset($licenses[3], $licenses[6]); } //if ($modification == 'sharealike') { // including // 1: Attribution NonCommercial ShareAlike // 5: Attribution ShareAlike //unset($licenses[2], $licenses[3], $licenses[4], $licenses[6], $licenses[7]); //} $licenses = implode(',', $licenses); $tag = !empty($SESSION->{$this->sess_tag}) ? $SESSION->{$this->sess_tag} : null; $text = !empty($SESSION->{$this->sess_text}) ? $SESSION->{$this->sess_text} : null; $nsid = !empty($this->nsid) ? $this->nsid : null; $photos = $this->flickr->photos_search( array( 'tags' => $tag, 'page' => $page, 'per_page' => 24, 'user_id' => $nsid, 'license' => $licenses, 'text' => $text, 'extras' => 'original_format,license,date_upload,last_update', 'media' => 'photos' ) ); $ret['total'] = $photos['total']; $ret['perpage'] = $photos['perpage']; if (empty($photos)) { $ret['list'] = array(); return $ret; } $ret = $this->build_list($photos, $page, $ret); $ret['list'] = array_filter($ret['list'], array($this, 'filter')); return $ret; } /** * return an image list * * @param string $path * @param int $page * @return array */ public function get_listing($path = '', $page = 1) { $people = $this->flickr->people_findByEmail($this->flickr_account); $this->nsid = $people['nsid']; $photos = $this->flickr->people_getPublicPhotos($people['nsid'], 'original_format,license,date_upload,last_update', 24, $page); $ret = array(); return $this->build_list($photos, $page, $ret); } /** * build an image list * * @param array $photos * @param int $page * @return array */ private function build_list($photos, $page, &$ret) { global $OUTPUT; if (!empty($this->nsid)) { $photos_url = $this->flickr->urls_getUserPhotos($this->nsid); $ret['manage'] = $photos_url; } $ret['list'] = array(); $ret['nosearch'] = true; $ret['norefresh'] = true; $ret['logouttext'] = get_string('backtosearch', 'repository_flickr_public'); $ret['pages'] = $photos['pages']; if (is_int($page) && $page <= $ret['pages']) { $ret['page'] = $page; } else { $ret['page'] = 1; } if (!empty($photos['photo'])) { foreach ($photos['photo'] as $p) { if(empty($p['title'])) { $p['title'] = get_string('notitle', 'repository_flickr'); } if (isset($p['originalformat'])) { $format = $p['originalformat']; } else { $format = 'jpg'; } $format = '.'.$format; if (substr($p['title'], strlen($p['title'])-strlen($format)) != $format) { // append author id // $p['title'] .= '-'.$p['owner']; // append file extension $p['title'] .= $format; } // Get the thumbnail source URL. $thumbnailsource = $this->flickr->buildPhotoURL($p, 'Square'); if (!@getimagesize($thumbnailsource)) { // Use the file extension icon as a thumbnail if the original thumbnail does not exist to avoid // displaying broken thumbnails in the repository. $thumbnailsource = $OUTPUT->image_url(file_extension_icon($p['title']))->out(false); } // Perform a HEAD request to the image to obtain it's Content-Length. $curl = new curl(); $curl->head($this->get_link($p['id'])); // The photo sizes are statically cached, so we can retrieve image dimensions without another API call. $bestsize = $this->get_best_size($p['id']); $ret['list'][] = array( 'title' => $p['title'], 'source' => $p['id'], 'id' => $p['id'], 'thumbnail' => $thumbnailsource, 'datecreated' => $p['dateupload'], 'datemodified' => $p['lastupdate'], 'size' => (int)($curl->get_info()['download_content_length']), 'image_width' => $bestsize['width'], 'image_height' => $bestsize['height'], 'url' => 'http://www.flickr.com/photos/' . $p['owner'] . '/' . $p['id'], 'license' => $this->license4moodle($p['license']), 'author' => $p['owner'], ); } } return $ret; } /** * Print a search form * * @return string */ public function print_search() { $str = ''; $str .= ''; $str .= ''; $str .= ''; $str .= '

'; $str .= '

'; return $str; } /** * Return photo url by given photo id * @param string $photoid * @return string */ private function build_photo_url($photoid) { $bestsize = $this->get_best_size($photoid); if (!isset($bestsize['source'])) { throw new repository_exception('cannotdownload', 'repository'); } return $bestsize['source']; } /** * Returns the best size for a photo * * @param string $photoid the photo identifier * @return array of information provided by the API */ protected function get_best_size($photoid) { if (!isset(self::$sizes[$photoid])) { // Sizes are returned from smallest to greatest. self::$sizes[$photoid] = $this->flickr->photos_getSizes($photoid); } $sizes = self::$sizes[$photoid]; $bestsize = array(); if (is_array($sizes)) { while ($bestsize = array_pop($sizes)) { // Make sure the source is set. Exit the loop if found. if (isset($bestsize['source'])) { break; } } } return $bestsize; } public function get_link($photoid) { return $this->build_photo_url($photoid); } /** * * @global object $CFG * @param string $photoid * @param string $file * @return string */ public function get_file($photoid, $file = '') { global $CFG; $info = $this->flickr->photos_getInfo($photoid); // If we can read the original secret, it means that we have access to the original picture. if (isset($info['originalsecret'])) { $source = $this->flickr->buildPhotoURL($info, 'original'); } else { $source = $this->build_photo_url($photoid); } // Make sure the source image exists. if (!@getimagesize($source)) { throw new moodle_exception('cannotdownload', 'repository'); } if ($info['owner']['realname']) { $author = $info['owner']['realname']; } else { $author = $info['owner']['username']; } $copyright = get_string('author', 'repository') . ': ' . $author; $result = parent::get_file($source, $file); $path = $result['path']; if (!empty($this->usewatermarks)) { $img = new moodle_image($path); $img->watermark($copyright, array(10,10), array('ttf'=>true, 'fontsize'=>12))->saveas($path); } return array('path'=>$path, 'author'=>$info['owner']['realname'], 'license'=>$this->license4moodle($info['license'])); } /** * Add Instance settings input to Moodle form * @param object $mform */ public static function instance_config_form($mform) { $mform->addElement('text', 'email_address', get_string('emailaddress', 'repository_flickr_public')); $mform->setType('email_address', PARAM_RAW_TRIMMED); // This is for sending to flickr. Not our job to validate it. $mform->addElement('checkbox', 'usewatermarks', get_string('watermark', 'repository_flickr_public')); $mform->setDefault('usewatermarks', 0); } /** * Names of the instance settings * @return array */ public static function get_instance_option_names() { return array('email_address', 'usewatermarks'); } /** * Add Plugin settings input to Moodle form * @param object $mform */ public static function type_config_form($mform, $classname = 'repository') { $api_key = get_config('flickr_public', 'api_key'); if (empty($api_key)) { $api_key = ''; } $strrequired = get_string('required'); $mform->addElement('text', 'api_key', get_string('apikey', 'repository_flickr_public'), array('value'=>$api_key,'size' => '40')); $mform->setType('api_key', PARAM_RAW_TRIMMED); $mform->addRule('api_key', $strrequired, 'required', null, 'client'); $mform->addElement('static', null, '', get_string('information','repository_flickr_public')); } /** * Names of the plugin settings * @return array */ public static function get_type_option_names() { return array('api_key', 'pluginname'); } /** * is run when moodle administrator add the plugin */ public static function plugin_init() { //here we create a default instance for this type $id = repository::static_function('flickr_public','create', 'flickr_public', 0, context_system::instance(), array('name'=>'', 'email_address' => null, 'usewatermarks' => false), 0); if (empty($id)) { return false; } else { return true; } } public function supported_filetypes() { return array('web_image'); } public function supported_returntypes() { return (FILE_INTERNAL | FILE_EXTERNAL); } /** * Return the source information * * @param string $photoid photo id * @return string|null */ public function get_file_source_info($photoid) { return $this->build_photo_url($photoid); } /** * Is this repository accessing private data? * * @return bool */ public function contains_private_data() { return false; } } version.php000064400000002322152266404430006747 0ustar00. /** * Version details * * @package repository * @subpackage flickr_public * @copyright 2009 Dongsheng Cai * @author Dongsheng Cai * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $plugin->version = 2025041400; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2025040800; // Requires this Moodle version. $plugin->component = 'repository_flickr_public'; // Full name of the plugin (used for diagnostics) classes/privacy/provider.php000064400000010411152266404430012224 0ustar00. /** * Privacy Subsystem implementation for repository_flickr_public. * * @package repository_flickr_public * @copyright 2018 Zig Tan * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace repository_flickr_public\privacy; use core_privacy\local\metadata\collection; use core_privacy\local\request\approved_contextlist; use core_privacy\local\request\approved_userlist; use core_privacy\local\request\context; use core_privacy\local\request\contextlist; use core_privacy\local\request\userlist; defined('MOODLE_INTERNAL') || die(); /** * Privacy Subsystem for repository_flickr_public implementing metadata and plugin providers. * * @copyright 2018 Zig Tan * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements \core_privacy\local\metadata\provider, \core_privacy\local\request\core_userlist_provider, \core_privacy\local\request\plugin\provider { /** * Returns meta data about this system. * * @param collection $collection The initialised collection to add items to. * @return collection A listing of user data stored through this system. */ public static function get_metadata(collection $collection): collection { $collection->add_external_location_link( 'flickr.com', [ 'author' => 'privacy:metadata:repository_flickr_public:author', 'email_address' => 'privacy:metadata:repository_flickr_public:email_address', 'text' => 'privacy:metadata:repository_flickr_public:text', 'user_id' => 'privacy:metadata:repository_flickr_public:user_id' ], 'privacy:metadata:repository_flickr_public' ); return $collection; } /** * Get the list of contexts that contain user information for the specified user. * * @param int $userid The user to search. * @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin. */ public static function get_contexts_for_userid(int $userid): contextlist { return new contextlist(); } /** * Get the list of users who have data within a context. * * @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination. */ public static function get_users_in_context(userlist $userlist) { } /** * Export all user data for the specified user, in the specified contexts. * * @param approved_contextlist $contextlist The approved contexts to export information for. */ public static function export_user_data(approved_contextlist $contextlist) { } /** * Delete all data for all users in the specified context. * * @param context $context The specific context to delete data for. */ public static function delete_data_for_all_users_in_context(\context $context) { } /** * Delete all user data for the specified user, in the specified contexts. * * @param approved_contextlist $contextlist The approved contexts and user information to delete information for. */ public static function delete_data_for_user(approved_contextlist $contextlist) { } /** * Delete multiple users within a single context. * * @param approved_userlist $userlist The approved context and user information to delete information for. */ public static function delete_data_for_users(approved_userlist $userlist) { } } tests/generator/lib.php000064400000003750152266404430011166 0ustar00. /** * Flickr Public repository data generator * * @package repository_flickr_public * @category test * @copyright 2013 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Flickr Public repository data generator class * * @package repository_flickr_public * @category test * @copyright 2013 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class repository_flickr_public_generator extends testing_repository_generator { /** * Fill in record defaults. * * @param array $record * @return array */ protected function prepare_record(array $record) { $record = parent::prepare_record($record); if (!isset($record['email_address'])) { $record['email_address'] = ''; } if (!isset($record['usewatermarks'])) { $record['usewatermarks'] = 0; } return $record; } /** * Fill in type record defaults. * * @param array $record * @return array */ protected function prepare_type_record(array $record) { $record = parent::prepare_type_record($record); if (!isset($record['api_key'])) { $record['api_key'] = 'api_key'; } return $record; } }