Location: PHPKode > projects > Aratix > aratix/admin/classes/Extension.class.php
<?php
/*
** Aratix
** Version 0.1.0beta8 (Anubis)
**
** Autor: Manuel Burghammer
** E-Mail: hide@address.com
** Homepage: http://www.xitara.net
**
** File: Extension.class.php - Version 0.1.0 build 104
** Position: /admin/classes/
** Last Modified: 07.06.2006 - 21:41:26
*/

class Extension{
	function __construct(){
// 		$this->menu_item = array (	"overview",
// 									"add");
	}
	function install(){

	}
	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('art') == "block")
			$aligns = array("left", "right", "top", "bottom");
		else
			$aligns = array("left");

		if(!get('order') && get('art') == "block")
			$order = "position ASC";
		else
			$order =  get('order'). " " . get('dir');

		if($order == " ")
			$order = "id ASC";

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

		foreach($aligns as $align){
			if(get('art') == "block")
				$where = "align='" . $align . "'";
			else
				$where = "1";

			if($status == 99999)
				$extension_list[$align] = $db->read_array(TB_PREFIX . get('art') . "s", "*", $where, $order, $limit);
			else{
				$groups_ = $db->read(TB_USER, "extension_admin", "id='" . $id . "'");
				$groups = explode(" ", $groups_['extension_admin']);

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

					if($groups[count($groups) - 1] != $group)
						$group_list .= " OR ";
				}
				$extension_list[$align] = $db->read_array(TB_PREFIX . get('art') . "s", "*", $where . "' AND " . $group_list, $order, $limit);
			}
		}
		$this->extension_list = $extension_list;

		return $extension_list;
	}
	function activate(){

	}
	function deactivate(){

	}
	function delete(){

	}
	function get_menupos_dropdown($position, $extension_id, $align){
		$menupos_dropdown = "<select id=\"menupos_" . $extension_id . "\" onchange=\"change_menupos('" . $extension_id . "', '" . $align . "')\" class=\"extension_dropdown\">\n";
		$menupos_dropdown .= "<option value=\"5\"";

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

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

		for($count = 1; $count < count($this->extension_list[$align]); $count++){
			$extension = $this->extension_list[$align][$count - 1];

 			if($extension_id != $this->extension_list[$align][$count - 1]['id']){
				$menupos_dropdown .= "<option value=\"" . ($extension['position'] + 5) . "\"";

				if($position == $this->extension_list[$align][$count]['position'])
					$menupos_dropdown .= " selected";

				if($position == "10")
					$menu_text = $GLOBALS['config']->i18n("core_to_top");
				else
					$menu_text = $GLOBALS['config']->i18n("core_after") . " " . $this->extension_list[$align][$count - 1]['name'];

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

			if($count == count($this->extension_list[$align]) - 1)
				$menupos_dropdown .= " selected";

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

		return $menupos_dropdown;
	}
	function change_menupos($db, $id, $new_position){
		$db->update(TB_PREFIX . get('art') . "s", "position", $new_position, "id=" . $id);
		$list = $db->read_array(TB_PREFIX . get('art') . "s", "*", "align='" . get('align') . "'", "position ASC");

		$counter = 10;

		foreach($list as $entry){
			$db->update(TB_PREFIX . get('art') . "s", "position", $counter, "id=" . $entry['id']);
			$counter += 10;
		}
	}
	function change_align($db, $id){
		$db->update(TB_PREFIX . get('art') . "s", "align", get('align'), "id=" . $id);

		$alings = array("left", "right", "top", "bottom");

		foreach($alings as $align){
			$list = $db->read_array(TB_PREFIX . get('art') . "s", "*", "align='" . $align . "'", "position ASC");

			$counter = 10;

			foreach($list as $entry){
				$db->update(TB_PREFIX . get('art') . "s", "position", $counter, "id=" . $entry['id']);
				$counter += 10;
			}
		}
	}
	function change_groups($db){
		if(get('group_acc')){
			$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++;
			}
		}
		else
			$query = "";

		$db->update(TB_PREFIX . get('art') . "s", "groups", $query, "id='" . get('id') . "'");
	}
	function change_category($db){
		if(get('category_list')){
			$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++;
			}
		}
		else
			$query = "";

		$db->update(TB_PREFIX . get('art') . "s", "categories", $query, "id='" . get('id') . "'");
	}
}
?>
Return current item: Aratix