예제 #1
0
 function insert()
 {
     global $database_table_prefix;
     if (!empty($this->artist)) {
         $result = mysql_query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `" . $database_table_prefix . "artist`\n\t\t\t\tWHERE `name` = '" . addslashes($this->artist) . "'\n\t\t\t") or die(mysql_error());
         if (mysql_num_rows($result) == 0) {
             $artist = new artist();
             $artist->name = $this->artist;
             $artist->insert();
             $this->artist_id = $artist->id;
         } else {
             while ($data = mysql_fetch_object($result)) {
                 $this->artist_id = $data->id;
             }
         }
     }
     if (!empty($this->album)) {
         $result = mysql_query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM `" . $database_table_prefix . "album`\n\t\t\t\tWHERE `name` = '" . addslashes($this->album) . "'\n\t\t\t\tAND `artist` = '" . addslashes($this->artist_id) . "'\n\t\t\t") or die(mysql_error());
         if (mysql_num_rows($result) == 0) {
             $album = new album();
             $album->name = $this->album;
             $album->artist = $this->artist_id;
             $album->insert();
             $this->album_id = $album->id;
         } else {
             while ($data = mysql_fetch_object($result)) {
                 $this->album_id = $data->id;
             }
         }
     }
     $result = mysql_query("\n\t\t\tINSERT \n\t\t\tINTO `" . $database_table_prefix . "song`\n\t\t\t( `name`\n\t\t\t, `rating`\n\t\t\t, `play_count`\n\t\t\t, `artist`\n\t\t\t, `album`\n\t\t\t)\n\t\t\tVALUES \n\t\t\t( '" . addslashes($this->name) . "'\n\t\t\t, '" . addslashes($this->rating) . "'\n\t\t\t, '" . addslashes($this->play_count) . "'\n\t\t\t, '" . addslashes($this->artist_id) . "'\n\t\t\t, '" . addslashes($this->album_id) . "'\n\t\t\t)\n\t\t") or die(mysql_error());
     $this->id = mysql_insert_id();
 }
예제 #2
0
파일: ajax.php 프로젝트: Ashaan/phpgallery
 function comGetImage()
 {
     if (isset($this->data['page']) && isset($this->data['count'])) {
         $listMedia = $this->album->getMedia($this->data['id'], null, $this->data['page'], $this->data['count']);
     } else {
         $listMedia = $this->album->getMedia($this->data['id']);
         $this->data['page'] = 1;
         $this->data['count'] = count($listMedia);
     }
     $xml = '<?xml version="1.0" encoding="UTF-8" ?>
   <RESPONSE>
     <INFO>
       <COMMAND>' . $this->command . '</COMMAND>
       <ID>' . $this->data['id'] . '</ID>
       <PAGE>' . $this->data['page'] . '</PAGE>
       <COUNT>' . $this->data['count'] . '</COUNT>
     </INFO>
     <DATA>';
     foreach ($listMedia as $value) {
         $mime = explode('/', $value['mime']);
         $xml .= '
     <IMAGE>
       <ID>' . $value['id'] . '</ID>
       <ALBUM>' . $value['aid'] . '</ALBUM>
       <TITLE>' . $value['title'] . '</TITLE>
       <DESCRIPTION>' . $value['desc'] . '</DESCRIPTION>
       <WIDTH>' . $value['width'] . '</WIDTH>
       <HEIGHT>' . $value['height'] . '</HEIGHT>
       <DURATION>' . $value['duration'] . '</DURATION>
       <SIZE>' . $value['size'] . '</SIZE>
       <DATE>' . $value['firstdate'] . '</DATE>
       <MIME>
         <GROUP>' . $mime[0] . '</GROUP>
         <TYPE>' . $mime[1] . '</TYPE>
       </MIME>
       <USER>
         <ID>' . $value['uid'] . '</ID>
         <NAME>' . $value['username'] . '</NAME>
         <FIRSTNAME></FIRSTNAME>
         <LASTNAME></LASTNAME>
       </USER>
     </IMAGE>
   ';
     }
     $xml .= '
     </DATA>
   </RESPONSE>';
     $xml = preg_replace('/(\\s*)(.*)\\n/', "\\2\n", $xml);
     $xml = preg_replace('/>(\\s*)\\n(\\s*)</', "><", $xml);
     $this->html = $xml;
 }
예제 #3
0
파일: image.php 프로젝트: Ashaan/phpgallery
 protected function initialize()
 {
     $this->album = album::getInstance();
     if ($this->data['id'] == '-1') {
         $this->imageinfo = array('name' => 'album.png');
         $session = session::getInstance();
         $this->pathname = LOCAL_PATH . LOCAL_DIR . 'theme/' . $session->getData('theme') . '/image/';
     } else {
         $this->imageinfo = $this->album->getMediaInfo($this->data['id']);
         $this->pathname = LOCAL_PATH . LOCAL_DIR . 'data/' . $this->imageinfo['path'] . '/';
     }
     if (!$this->imageinfo) {
         $this->error('4', 'album inexistant');
     }
     $this->width = isset($this->data['w']) ? $this->data['w'] : false;
     $this->height = isset($this->data['h']) ? $this->data['h'] : false;
     $this->mask = isset($this->data['m']) ? $this->data['m'] : false;
     $this->trans = isset($this->data['t']) ? $this->data['t'] : false;
     $this->pathcache = LOCAL_PATH . LOCAL_DIR . 'cache/';
     $this->filecache = $this->getCacheName();
     $this->filename = $this->imageinfo['name'];
     $mime = parse_ini_file('include/mime.ini');
     $this->mime = $mime[strtolower(substr($this->imageinfo['name'], strrpos($this->imageinfo['name'], '.') + 1, strlen($this->imageinfo['name'])))];
     if (!$this->mime) {
         return false;
     }
     $this->type = explode('/', $this->mime);
 }
예제 #4
0
파일: album.php 프로젝트: Ashaan/phpgallery
 public static function getInstance()
 {
     if (is_null(album::$instance)) {
         album::$instance = new album();
     }
     return album::$instance;
 }
예제 #5
0
 public function resize_url_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $album = album::create($root, $rand, $rand, $rand);
     $photo = photo::create($album, MODPATH . "gallery/tests/test.jpg", "{$rand}.jpg", $rand, $rand);
     $this->assert_equal("http://./var/resizes/{$rand}/{$rand}.jpg", $photo->resize_url());
 }
예제 #6
0
 public function create_photo_creates_reasonable_slug_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $album = album::create($root, $rand, $rand, $rand);
     $photo = photo::create($album, MODPATH . "gallery/tests/test.jpg", "This (is) my file%name.jpg", $rand, $rand);
     $this->assert_equal("This-is-my-file-name", $photo->slug);
 }
 /**
  **/
 function getAlbum($id)
 {
     $result = array();
     $sql = " SELECT SQL_NO_CACHE * FROM Album WHERE IDAlbum = :id ";
     $params = array(":id" => $id);
     $sth = $this->db->prepare($sql);
     $sth->execute($params);
     if ($sth->rowCount() == 1) {
         $response = $sth->fetch(PDO::FETCH_OBJ);
         $album = new album();
         //-----
         $album->init($response->IDAlbum, $response->Title, $response->Cover, $response->Artist);
         $album->setTracks($this->getAlbumTracks($response->IDAlbum));
         array_push($result, $album);
     }
     return $result;
 }
예제 #8
0
파일: album.php 프로젝트: Ashaan/phpgallery
 public function initialize()
 {
     $this->template = template::getInstance();
     $this->session = session::getInstance();
     $this->album = album::getInstance();
     $this->template->add(array('album'));
     $this->id = $this->session->getData('album', 'id');
     $this->page = $this->session->getData('album', 'page');
 }
예제 #9
0
 public function deleting_an_item_deletes_its_comments_too_test()
 {
     $rand = rand();
     $album = album::create(ORM::factory("item", 1), "test_{$rand}", "test_{$rand}");
     $comment = comment::create($album, identity::guest(), "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $album->delete();
     $deleted_comment = ORM::factory("comment", $comment->id);
     $this->assert_false($deleted_comment->loaded);
 }
 private function _get_form()
 {
     $form = new Forge("admin/default_sort", "", "post", array("id" => "g-admin-default_sort-form"));
     $group = $form->group("sort_order")->label(t("Sort Order"));
     $group->dropdown("sort_column")->id(t("sort_column"))->label(t("Sort by"))->options(array_merge(array("none" => t("None")), album::get_sort_order_options()))->selected(module::get_var("default_sort", "default_sort_column", "none"));
     $group->dropdown("sort_direction")->id(t("sort_direction"))->label(t("Sort by"))->options(array("none" => t("None"), "ASC" => t("Ascending"), "DESC" => t("Descending")))->selected(module::get_var("default_sort", "default_sort_direction", "none"));
     $form->submit("submit")->value(t("Save"));
     return $form;
 }
예제 #11
0
 static function add_from_server($task)
 {
     $context = unserialize($task->context);
     try {
         $paths = array_keys(unserialize(module::get_var("server_add", "authorized_paths")));
         $path = $paths[$context["next_path"]];
         if (!empty($context["files"][$path])) {
             $file = $context["files"][$path][$context["position"]];
             $parent = ORM::factory("item", $file["parent_id"]);
             access::required("server_add", $parent);
             access::required("add", $parent);
             if (!$parent->is_album()) {
                 throw new Exception("@todo BAD_ALBUM");
             }
             $name = $file["name"];
             if ($file["type"] == "album") {
                 $album = ORM::factory("item")->where("name", $name)->where("parent_id", $parent->id)->find();
                 if (!$album->loaded) {
                     $album = album::create($parent, $name, $name, null, user::active()->id);
                 }
                 // Now that we have a new album. Go through the remaining files to import and change the
                 // parent_id of any file that has the same relative path as this album's path.
                 $album_path = "{$file['path']}/{$name}";
                 for ($idx = $context["position"] + 1; $idx < count($context["files"][$path]); $idx++) {
                     if (strpos($context["files"][$path][$idx]["path"], $album_path) === 0) {
                         $context["files"][$path][$idx]["parent_id"] = $album->id;
                     }
                 }
             } else {
                 $extension = strtolower(substr(strrchr($name, '.'), 1));
                 $source_path = "{$path}{$file['path']}/{$name}";
                 if (in_array($extension, array("flv", "mp4"))) {
                     $movie = movie::create($parent, $source_path, $name, $name, null, user::active()->id);
                 } else {
                     $photo = photo::create($parent, $source_path, $name, $name, null, user::active()->id);
                 }
             }
             $context["counter"]++;
             if (++$context["position"] >= count($context["files"][$path])) {
                 $context["next_path"]++;
                 $context["position"] = 0;
             }
         } else {
             $context["next_path"]++;
         }
     } catch (Exception $e) {
         $context["errors"][$path] = $e->getMessage();
     }
     $task->context = serialize($context);
     $task->state = "success";
     $task->percent_complete = $context["counter"] / (double) $context["total"] * 100;
     $task->done = $context["counter"] == (double) $context["total"];
 }
예제 #12
0
 public function create_album_silently_trims_trailing_periods_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     try {
         $album = album::create($root, $rand . "..", $rand, $rand);
     } catch (Exception $e) {
         $this->assert_equal("@todo NAME_CANNOT_END_IN_PERIOD", $e->getMessage());
         return;
     }
     $this->assert_true(false, "Shouldn't create an album with trailing . in the name");
 }
예제 #13
0
 public function viewable_test()
 {
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $item = self::_create_random_item($album);
     identity::set_active_user(identity::guest());
     // We can see the item when permissions are granted
     access::allow(identity::everybody(), "view", $album);
     $this->assert_equal(1, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
     // We can't see the item when permissions are denied
     access::deny(identity::everybody(), "view", $album);
     $this->assert_equal(0, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
 }
예제 #14
0
 public function cant_view_comments_for_unviewable_items_test()
 {
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $comment = comment::create($album, user::guest(), "text", "name", "email", "url");
     user::set_active(user::guest());
     // We can see the comment when permissions are granted on the album
     access::allow(group::everybody(), "view", $album);
     $this->assert_equal(1, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
     // We can't see the comment when permissions are denied on the album
     access::deny(group::everybody(), "view", $album);
     $this->assert_equal(0, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
 }
예제 #15
0
 public function setup()
 {
     $this->_server = $_SERVER;
     $root = ORM::factory("item", 1);
     $this->_album = album::create($root, rand(), "test album");
     access::deny(identity::everybody(), "view_full", $this->_album);
     access::deny(identity::registered_users(), "view_full", $this->_album);
     $rand = rand();
     $this->_item = photo::create($this->_album, MODPATH . "gallery/tests/test.jpg", "{$rand}.jpg", $rand, $rand);
     $this->_proxy = ORM::factory("digibug_proxy");
     $this->_proxy->uuid = md5(rand());
     $this->_proxy->item_id = $this->_item->id;
     $this->_proxy->save();
 }
예제 #16
0
 protected function initialize()
 {
     if (!isset($this->data['type']) || !isset($this->data['version'])) {
         $this->error('2', 'Paramettre manquant');
     }
     $this->album = album::getInstance();
     $this->albuminfo = $this->album->getInfo($this->data['id']);
     if (!$this->albuminfo) {
         $this->error('4', 'album inexistant');
     }
     $this->pathcache = LOCAL_PATH . LOCAL_DIR . 'cache/';
     $this->pathname = LOCAL_PATH . LOCAL_DIR . 'data/';
     $this->filecache = 'a' . $this->data['id'] . '_' . $this->data['version'] . '.' . $this->data['type'];
 }
예제 #17
0
 public function change_album_no_csrf_fails_test()
 {
     $controller = new Albums_Controller();
     $root = ORM::factory("item", 1);
     $this->_album = album::create($root, "test", "test", "test");
     $_POST["name"] = "new name";
     $_POST["title"] = "new title";
     $_POST["description"] = "new description";
     access::allow(group::everybody(), "edit", $root);
     try {
         $controller->_update($this->_album);
         $this->assert_true(false, "This should fail");
     } catch (Exception $e) {
         // pass
     }
 }
예제 #18
0
 public function move_to_test()
 {
     $root = ORM::factory("item", 1);
     $album1 = album::create($root, "move_to_test_1", "move_to_test_1");
     $album1_1 = album::create($album1, "move_to_test_1_1", "move_to_test_1_1");
     $album1_2 = album::create($album1, "move_to_test_1_2", "move_to_test_1_2");
     $album1_1_1 = album::create($album1_1, "move_to_test_1_1_1", "move_to_test_1_1_1");
     $album1_1_2 = album::create($album1_1, "move_to_test_1_1_2", "move_to_test_1_1_2");
     $album1_2->reload();
     $album1_1_1->reload();
     $album1_1_1->move_to($album1_2);
     $album1_1->reload();
     $album1_2->reload();
     $this->assert_equal(3, $album1_1->right - $album1_1->left);
     $this->assert_equal(3, $album1_2->right - $album1_2->left);
     $this->assert_equal(array($album1_1_2->id => "move_to_test_1_1_2"), $album1_1->children()->select_list());
     $this->assert_equal(array($album1_1_1->id => "move_to_test_1_1_1"), $album1_2->children()->select_list());
 }
예제 #19
0
파일: Tag_Test.php 프로젝트: xafr/gallery3
 public function create_tag_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $album = album::create($root, $rand, $rand, $rand);
     $tag1 = "tag1";
     tag::add($album, $tag1);
     $tag = ORM::factory("tag")->where("name", $tag1)->find();
     $this->assert_true(1, $tag->count);
     // Make sure adding the tag again doesn't increase the count
     tag::add($album, $tag1);
     $tag = ORM::factory("tag")->where("name", $tag1)->find();
     $this->assert_true(1, $tag->count);
     $rand = rand();
     $album = album::create($root, $rand, $rand, $rand);
     tag::add($album, $tag1);
     $tag = ORM::factory("tag")->where("name", $tag1)->find();
     $this->assert_true(2, $tag->count);
 }
예제 #20
0
파일: index.php 프로젝트: Ashaan/phpgallery
 private function loadParam()
 {
     $param = $_GET;
     if (isset($param['p'])) {
         $data = unserialize(base64_decode($param['p']));
         foreach ($data as $name => $value) {
             $param[$name] = $value;
         }
     }
     $session = session::getInstance();
     $album = album::getInstance();
     if (isset($param['theme'])) {
         $session->setData('theme', $param['theme']);
     }
     if (isset($param['template'])) {
         $session->setData('template', $param['template']);
     }
     if (isset($param['template']) || isset($param['theme'])) {
         $session->save();
         header('location: http://' . LOCAL_URL . LOCAL_DIR);
         echo 1;
     }
     if (isset($param['mode']) && isset($param['id'])) {
         if ($session->getData($param['mode'], 'id') != $param['id']) {
             if ($param['mode'] == 'album') {
                 $parent = $this->album->getParent($session->getData('album', 'id'));
                 $parent2 = $this->album->getParent($session->getData('album', 'lastId'));
                 if (!in_array($param['id'], $parent) && !in_array($param['id'], $parent2)) {
                     $session->setData('album', 'lastId', $param['id']);
                 }
             }
             $session->setData($param['mode'], 'page', 1);
             $session->setData($param['mode'], 'id', $param['id']);
         }
     }
     if (isset($param['mode']) && $param['mode'] != $session->getData('mode')) {
         $session->setData('mode', $param['mode']);
     }
     if (isset($param['page'])) {
         $session->setData($session->getData('mode'), 'page', $param['page']);
     }
 }
예제 #21
0
파일: album.php 프로젝트: kandsten/gallery3
 static function get_edit_form($parent)
 {
     $form = new Forge("albums/update/{$parent->id}", "", "post", array("id" => "g-edit-album-form"));
     $form->hidden("from_id")->value($parent->id);
     $group = $form->group("edit_item")->label(t("Edit Album"));
     $group->input("title")->label(t("Title"))->value($parent->title)->error_messages("required", t("You must provide a title"))->error_messages("length", t("Your title is too long"));
     $group->textarea("description")->label(t("Description"))->value($parent->description);
     if ($parent->id != 1) {
         $group->input("name")->label(t("Directory Name"))->value($parent->name)->error_messages("conflict", t("There is already a movie, photo or album with this name"))->error_messages("no_slashes", t("The directory name can't contain a \"/\""))->error_messages("no_trailing_period", t("The directory name can't end in \".\""))->error_messages("required", t("You must provide a directory name"))->error_messages("length", t("Your directory name is too long"));
         $group->input("slug")->label(t("Internet Address"))->value($parent->slug)->error_messages("conflict", t("There is already a movie, photo or album with this internet address"))->error_messages("not_url_safe", t("The internet address should contain only letters, numbers, hyphens and underscores"))->error_messages("required", t("You must provide an internet address"))->error_messages("length", t("Your internet address is too long"));
     } else {
         $group->hidden("name")->value($parent->name);
         $group->hidden("slug")->value($parent->slug);
     }
     $sort_order = $group->group("sort_order", array("id" => "g-album-sort-order"))->label(t("Sort Order"));
     $sort_order->dropdown("column", array("id" => "g-album-sort-column"))->label(t("Sort by"))->options(album::get_sort_order_options())->selected($parent->sort_column);
     $sort_order->dropdown("direction", array("id" => "g-album-sort-direction"))->label(t("Order"))->options(array("ASC" => t("Ascending"), "DESC" => t("Descending")))->selected($parent->sort_order);
     module::event("item_edit_form", $parent, $form);
     $group = $form->group("buttons")->label("");
     $group->hidden("type")->value("album");
     $group->submit("")->value(t("Modify"));
     return $form;
 }
예제 #22
0
          <?php 
echo $micro_thumb_grid;
?>
        </ul>
      </div>
      <div id="g-organize-controls" class="ui-widget-header">
        <a id="g-organize-close" href="#" ref="done"
           class="g-button g-right ui-corner-all ui-state-default"><?php 
echo t("Close");
?>
</a>
        <form>
          <?php 
echo t("Sort order");
?>
          <?php 
echo form::dropdown(array("id" => "g-organize-sort-column"), album::get_sort_order_options(), $album->sort_column);
?>
          <?php 
echo form::dropdown(array("id" => "g-organize-sort-order"), array("ASC" => "Ascending", "DESC" => "Descending"), $album->sort_order);
?>
        </form>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript">
  $("#g-organize").ready($.organize.init);
</script>
예제 #23
0
 public function move_album_test()
 {
     // Create an album with a photo in it
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $photo = ORM::factory("item");
     $photo->name = rand();
     $photo->type = "photo";
     $photo->add_to_parent($album);
     file_put_contents($photo->thumb_path(), "thumb");
     file_put_contents($photo->resize_path(), "resize");
     file_put_contents($photo->file_path(), "file");
     $original_album_name = $album->name;
     $original_photo_name = $photo->name;
     $new_album_name = rand();
     // Now rename the album
     $album->rename($new_album_name)->save();
     $photo->reload();
     // Expected:
     // * the album name changed.
     // * the album dirs are all moved
     // * the photo's paths are all inside the albums paths
     // * the photo files are all still intact and accessible
     $this->assert_equal($new_album_name, $album->name);
     $this->assert_equal($new_album_name, basename($album->file_path()));
     $this->assert_equal($new_album_name, basename(dirname($album->thumb_path())));
     $this->assert_equal($new_album_name, basename(dirname($album->resize_path())));
     $this->assert_same(0, strpos($photo->file_path(), $album->file_path()));
     $this->assert_same(0, strpos($photo->thumb_path(), dirname($album->thumb_path())));
     $this->assert_same(0, strpos($photo->resize_path(), dirname($album->resize_path())));
     $this->assert_equal("thumb", file_get_contents($photo->thumb_path()));
     $this->assert_equal("resize", file_get_contents($photo->resize_path()));
     $this->assert_equal("file", file_get_contents($photo->file_path()));
 }
예제 #24
0
<?php

error_reporting(0);
session_start();
if (isset($_SESSION['user'])) {
    $user = $_SESSION['user'];
} else {
    header("Location: ../views/signinPage.php?message=" . urlencode("Login Again!"));
}
$aerror = "";
if (isset($_POST['addAlbum'])) {
    $name = $_POST['name'];
    include_once '../models/album.php';
    if (album::insertAlbum($name, $user['username'])) {
        $aerror = "Album Created!";
        header("Location: ../views/allalbums.php");
    } else {
        $aerror = "Cannot Create a new Album!";
    }
}
?>
 
예제 #25
0
	<?php 
echo $navbar;
?>
	<div class="col-md-2" ></div>
	<div class="col-md-8" data-spy="scroll" data-target="#mynav">
        <div class="panel panel-primary">
			<div class="panel panel-heading">
				<h3><?php 
echo $temp['fullname'];
?>
's Albums</h3>
			</div>
			<div class="panel panel-body">
				<div class="col-md-12" >
					<?php 
$rs = album::getAllUserAlbum($temp['username']);
if ($rs == false) {
    echo "No Albums Present!";
} else {
    foreach ($rs as $row) {
        echo '<div class="col-md-3 form-group" ><input type = "button" class ="col-md-12 btn btn-success" id="' . $row['albumId'] . '" value = "' . $row['name'] . '" name = "' . $row['name'] . '" onclick=\'setalbum(id) \' /></div>';
    }
}
?>
					<div class="col-md-3 form-group" >
						<input type = "button" class ="col-md-12 btn btn-success" id="all" value = "All Others" name = "others" onclick='setall()'  />
					</div>
					<script>
						function setall()
						{
							var xmlhttp = new XMLHttpRequest();
예제 #26
0
 /**
  * Import a single album.
  */
 static function import_album(&$queue)
 {
     // The queue is a set of nested associative arrays where the key is the album id and the
     // value is an array of similar arrays.  We'll do a breadth first tree traversal using the
     // queue to keep our state.  Doing it breadth first means that the parent will be created by
     // the time we get to the child.
     // Dequeue the current album and enqueue its children
     list($g2_album_id, $children) = each($queue);
     unset($queue[$g2_album_id]);
     foreach ($children as $key => $value) {
         $queue[$key] = $value;
     }
     if (self::map($g2_album_id)) {
         return t("Album with id: %id already imported, skipping", array("id" => $g2_album_id));
     }
     try {
         // Load the G2 album item, and figure out its parent in G3.
         $g2_album = g2(GalleryCoreApi::loadEntitiesById($g2_album_id));
     } catch (Exception $e) {
         return t("Failed to import Gallery 2 album with id: %id\n%exception", array("id" => $g2_album_id, "exception" => $e->__toString()));
     }
     if ($g2_album->getParentId() == null) {
         return t("Skipping Gallery 2 root album");
     }
     $parent_album = ORM::factory("item", self::map($g2_album->getParentId()));
     $album = album::create($parent_album, $g2_album->getPathComponent(), self::_decode_html_special_chars($g2_album->getTitle()), self::_decode_html_special_chars(self::extract_description($g2_album)), self::map($g2_album->getOwnerId()));
     $album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
     $album->created = $g2_album->getCreationTimestamp();
     $order_map = array("originationTimestamp" => "captured", "creationTimestamp" => "created", "description" => "description", "modificationTimestamp" => "updated", "orderWeight" => "weight", "pathComponent" => "name", "summary" => "description", "title" => "title", "viewCount" => "view_count");
     $direction_map = array(ORDER_ASCENDING => "asc", ORDER_DESCENDING => "desc");
     if (array_key_exists($g2_order = $g2_album->getOrderBy(), $order_map)) {
         $album->sort_column = $order_map[$g2_order];
         $album->sort_order = $direction_map[$g2_album->getOrderDirection()];
     }
     $album->save();
     self::import_keywords_as_tags($g2_album->getKeywords(), $album);
     self::set_map($g2_album_id, $album->id);
     // @todo import album highlights
 }
예제 #27
0
 function sort_order($album_id, $col, $dir)
 {
     access::verify_csrf();
     $album = ORM::factory("item", $album_id);
     access::required("view", $album);
     access::required("edit", $album);
     $options = album::get_sort_order_options();
     if (!isset($options[$col])) {
         return;
     }
     $album->sort_column = $col;
     $album->sort_order = $dir;
     $album->save();
     print json_encode(array("grid" => self::_get_micro_thumb_grid($album, 0)->__toString(), "sort_column" => $album->sort_column, "sort_order" => $album->sort_order));
 }
예제 #28
0
 private static function _add_album_or_photo($desired_type = null)
 {
     srand(time());
     $parents = ORM::factory("item")->where("type", "album")->find_all()->as_array();
     $owner_id = user::active()->id;
     $test_images = glob(dirname(dirname(__FILE__)) . "/data/*.[Jj][Pp][Gg]");
     $parent = $parents[array_rand($parents)];
     $parent->reload();
     $type = $desired_type;
     if (!$type) {
         $type = rand(0, 10) ? "photo" : "album";
     }
     if ($type == "album") {
         $thumb_size = module::get_var("core", "thumb_size");
         $rand = rand();
         $parents[] = album::create($parent, "rnd_{$rand}", "Rnd {$rand}", "random album {$rand}", $owner_id)->save();
     } else {
         $photo_index = rand(0, count($test_images) - 1);
         photo::create($parent, $test_images[$photo_index], basename($test_images[$photo_index]), "rnd_" . rand(), "sample thumb", $owner_id);
     }
 }
예제 #29
0
 public function form_edit($id)
 {
     $item = model_cache::get("item", $id);
     access::required("view", $item);
     access::required("edit", $item);
     if ($item->is_album()) {
         $form = album::get_edit_form($item);
     } else {
         $form = photo::get_edit_form($item);
     }
     print $form;
 }
예제 #30
0
 public function everybody_view_full_permission_maintains_htaccess_files_test()
 {
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), "test album");
     $this->assert_false(file_exists($album->file_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
     access::deny(group::everybody(), "view_full", $album);
     $this->assert_true(file_exists($album->file_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
     access::allow(group::everybody(), "view_full", $album);
     $this->assert_false(file_exists($album->file_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
     access::deny(group::everybody(), "view_full", $album);
     $this->assert_true(file_exists($album->file_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
     access::reset(group::everybody(), "view_full", $album);
     $this->assert_false(file_exists($album->file_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
     $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
 }