Пример #1
0
 public function __construct($metas)
 {
     if ($metas instanceof Collection) {
         $this->ids = $metas->ids();
     } else {
         $this->ids = FrankizImage::toIds(unflatten($metas));
     }
 }
Пример #2
0
/**
 * Create an image for a promotion, for a group, if needed
 */
function create_promo_image(Group $g, $promo)
{
    $g->select(GroupSelect::base());
    if ($g->image()) {
        return;
    }
    if ($promo % 2 == 0) {
        $upload = FrankizUpload::fromFile(dirname(__FILE__) . '/../images/rouje.png');
        $label = 'Chic à la rouje';
    } else {
        $upload = FrankizUpload::fromFile(dirname(__FILE__) . '/../images/jone.png');
        $label = 'Chic à la jone';
    }
    $i = new FrankizImage();
    $i->insert();
    $i->caste($g->caste(Rights::everybody()));
    $i->label($label);
    $i->image($upload, false);
    $g->image($i);
}
Пример #3
0
         $n = $nf->get(true);
         $n->select(GroupSelect::castes());
         $n->caste(Rights::member())->addUser($u);
     }
 */
 //Photo
 $works = false;
 $suffix = '_original';
 $folder = '/home/2009/matthieu/photos';
 $original = true;
 $path = $folder . '/' . $u->hruid() . $suffix . '.jpg';
 if (file_exists($path)) {
     $upload = FrankizUpload::fromFile($path);
     if ($upload->size() > 0) {
         try {
             $i = new FrankizImage();
             $i->insert();
             $i->caste($tol_caste);
             $i->label($u->firstname() . ' ' . $u->lastname());
             $i->image($upload, false);
             if ($original) {
                 $u->original($i);
             } else {
                 $u->photo($i);
             }
             $works = true;
         } catch (Exception $e) {
             echo 'Error:' . $e->getMessage() . "\n";
         }
     }
 }
Пример #4
0
 function handler_links_admin($page)
 {
     if (!S::user()->perms()->hasFlag('admin')) {
         return PL_FORBIDDEN;
     }
     $collec = Link::all();
     $collec->select(LinkSelect::all());
     $results = $collec->split('ns');
     if (Env::has('modify')) {
         $id = Env::i('id');
         $link = $collec->get($id);
         if ($link !== false) {
             if (Env::has('image')) {
                 try {
                     $group = Group::from('partnership');
                     $group->select();
                     $image = new FrankizImage();
                     $image->insert();
                     $image->label($link->label());
                     $image->caste($group->caste('everybody'));
                     $image->image(FrankizUpload::v('image'));
                     $link->image($image);
                 } catch (Exception $e) {
                     $page->assign('err', $e->getMessage());
                 }
             }
             $link->label(Env::t('label'));
             $link->link(Env::t('link'));
             $link->description(Env::t('description'));
             $link->comment(Env::t('comment'));
         } else {
             $err = 'Le lien modifié n\'existe plus.';
             $page->assign('err', $err);
         }
     }
     $page->addCssLink('links.css');
     $page->assign('links', $results);
     $page->assign('title', 'Administrer les liens');
     $page->changeTpl('links/admin_links.tpl');
 }
Пример #5
0
 /**
  * Current picture
  * /!\ The field must have been fetched even to set a new picture !
  *
  * @param $photo If specified, updates the picture in the database
  */
 public function photo(FrankizImage $photo = null)
 {
     if ($photo != null) {
         if ($this->photo) {
             $this->photo->delete();
         }
         $this->photo = $photo;
         XDB::execute('UPDATE account SET photo = {?} WHERE uid = {?}', $photo->id(), $this->id());
     }
     return $this->photo;
 }
Пример #6
0
 function handler_image($page, $size, $iid = null)
 {
     global $globals;
     $image = new FrankizImage($iid);
     $image->select(FrankizImageSelect::caste());
     $user = S::user();
     try {
         if ($user && $user->canSee($image->caste())) {
             $image->send($size);
             return;
         }
     } catch (DataNotFetchedException $e) {
     }
     // Not found of error => HTTP 403
     header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
     $img = new StaticImage($globals->images->forbidden);
     $img->send($size);
 }