Location: PHPKode > projects > Aratix > aratix/admin/classes/Images.class.php
<?php
/*
** Aratix
** Version 0.2.2beta9 (Anubis)
**
** Autor: Manuel Burghammer
** E-Mail: hide@address.com
** Homepage: http://www.xitara.net
**
** File: Images.class.php - Version 0.2.2 build 52
** Position: /admin/classes/
** Last Modified: 13.05.2006 - 23:56:10
*/

class Images{
	function __construct(){
		if(!defined("TB_IMAGES"))
			define("TB_IMAGES", TB_PREFIX . "images");

		$this->menu_item = array (	"overview",
									"add");
	}
	function overview($db, $ident){
		$group_list = "";
		$status_ = $db->read(TB_SESSION, "user_id, groups", "user_md5='" . $ident . "'");
		$status = $status_['groups'];
		$id = $status_['user_id'];

		if(!get('order'))
			$order = "name ASC";
		else
			$order =  get('order'). " " . get('dir');

		if(($start = get('start')) && $max = get('max'))
			$limit = $start . ", " . $max;
		else
			$limit = "";

		if($status == 99999)
			$image_list = $db->read_array(TB_IMAGES, "*", "id > 1", $order, $limit);
		else{
			$groups_ = $db->read(TB_USER, "category_admin", "id='" . $id . "'");
			$groups = explode(" ", $groups_['category_admin']);

			foreach($groups as $group){
				$group_list .= "groups LIKE '%|" . $group . "|%'";

				if($groups[count($groups) - 1] != $group)
					$group_list .= " OR ";
			}
			$image_list = $db->read_array(TB_IMAGES, "*", $group_list . "AND id > 1", $order, $limit);
		}
		$counter = 0;

		foreach($image_list as $image){
			$image_list_2[$counter] = $image;

			if($image['owner'] != 0)
				$image_list_2[$counter++]['owner_name'] = $GLOBALS['user']->get_username($image['owner']);
			else
				$image_list_2[$counter++]['owner_name'] = "GLOBAL";
		}
		if(isset($image_list_2))
			return $image_list_2;
		else
			return FALSE;
	}
	function add(){

	}
	function edit(){
		$image_data = $GLOBALS['db']->read(TB_IMAGES, "*", "id='" . get('image_id') . "'");
		return $image_data;
	}
	function delete(){

	}
	function get_menupos_dropdown($menu_pos, $image_id){
		$menupos_dropdown = "<select name=\"menupos_" . $image_id . "\" onchange=\"change_menupos('" . $image_id . "')\" class=\"images_dropdown\">\n";
		$menupos_dropdown .= "<option value=\"5\"";

		if($menu_pos == 10)
			$menupos_dropdown .= " selected";

		$menupos_dropdown .= ">" . $GLOBALS['config']->i18n("core_to_top") . "</option>\n";

		for($count = 1; $count < count($this->image_list); $count++){
			$image = $this->image_list[$count];

 			if($image_id != $this->image_list[$count - 1]['id']){
				$menupos_dropdown .= "<option value=\"" . ($image['menu_pos'] - 5) . "\"";

				if($menu_pos == $image['menu_pos'])
					$menupos_dropdown .= " selected";

				if($image['menu_pos'] == "10")
					$menu_text = $GLOBALS['config']->i18n("core_to_top");
				else
					$menu_text = " " . $GLOBALS['config']->i18n("core_after") . " " . $this->image_list[$count - 1]['menu_text'];

				$menupos_dropdown .= ">" . $menu_text . "</option>\n";
			}
		}
		if($image_id != $this->image_list[$count - 1]['id']){
			$menupos_dropdown .= "<option value=\"" . ($this->image_list[$count - 1]['menu_pos'] + 5) . "\"";

			if($count == count($this->image_list) - 1)
				$menupos_dropdown .= " selected";

			$menupos_dropdown .= ">" . $GLOBALS['config']->i18n("core_after") . " " . $this->image_list[$count - 1]['menu_text'] . "</option>\n";
		}
		$menupos_dropdown .= "</select>\n";

		return $menupos_dropdown;
	}
	function change_groups($db){
		$group_list = explode(";", get('group_acc'));
		$counter = 0;
		$query = "|";

		foreach($group_list as $group){
			$groups[$counter] = explode(",", $group);

			if($groups[$counter][1] == "true")
				 $query .= $groups[$counter][0] . "|";

			$counter++;
		}
		if($query == "|")
			$query = "";

		$db->update(TB_IMAGES, "groups", $query, "id='" . get('image_id') . "'");
	}
	function change_categories($db){
		$category_list = explode(";", get('category_list'));
		$counter = 0;
		$query = "|";

		foreach($category_list as $category){
			$categories[$counter] = explode(",", $category);

			if($categories[$counter][1] == "true")
				 $query .= $categories[$counter][0] . "|";

			$counter++;
		}
		$db->update(TB_IMAGES, "category", $query, "id='" . get('image_id') . "'");
	}
}
?>
Return current item: Aratix