Example #1
0
/**
 * Create the watermark image filename
 *
 * @param string $text
 * @param ElggUser $owner
 * @return string
 */
function tp_get_watermark_filename($text, $owner)
{
    $base = elgg_strtolower($text);
    $base = preg_replace("/[^\\w-]+/", "-", $base);
    $base = trim($base, '-');
    $filename = tp_get_img_dir();
    $filename .= elgg_strtolower($owner->username . "_" . $base . "_stamp");
    return $filename;
}
Example #2
0
 /**
  * Save an album
  *
  * @return bool
  */
 public function save()
 {
     if (!isset($this->new_album)) {
         $this->new_album = true;
     }
     if (!isset($this->last_notified)) {
         $this->last_notified = 0;
     }
     if (!parent::save()) {
         return false;
     }
     mkdir(tp_get_img_dir($this->guid), 0755, true);
     return true;
 }
Example #3
0
 /**
  * Save an album
  *
  * @return bool
  */
 public function save()
 {
     if (!isset($this->new_album)) {
         $this->new_album = true;
     }
     if (!isset($this->last_notified)) {
         $this->last_notified = 0;
     }
     if (!parent::save()) {
         return false;
     }
     mkdir(tp_get_img_dir() . $this->guid, 0755, true);
     elgg_trigger_event('create', 'album', $this);
     return true;
 }
Example #4
0
 /**
  * Save the uploaded image
  * 
  * @param array $data
  */
 protected function saveImageFile($data)
 {
     $this->checkUploadErrors($data);
     // we need to make sure the directory for the album exists
     // @note for group albums, the photos are distributed among the users
     $dir = tp_get_img_dir() . $this->getContainerGUID();
     if (!file_exists($dir)) {
         mkdir($dir, 0755, true);
     }
     // move the uploaded file into album directory
     $this->setOriginalFilename($data['name']);
     $filename = $this->getFilenameOnFilestore();
     $result = move_uploaded_file($data['tmp_name'], $filename);
     if (!$result) {
         return false;
     }
     $owner = $this->getOwnerEntity();
     $owner->image_repo_size = (int) $owner->image_repo_size + $this->size();
     return true;
 }