iconfig - add sharing variable
This commit is contained in:
		
							
								
								
									
										2
									
								
								boot.php
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								boot.php
									
									
									
									
									
								
							| @@ -51,7 +51,7 @@ define ( 'RED_VERSION',             trim(file_get_contents('version.inc'))); | ||||
| define ( 'STD_VERSION',             '1.2.3' ); | ||||
| define ( 'ZOT_REVISION',            1     ); | ||||
|  | ||||
| define ( 'DB_UPDATE_VERSION',       1162  ); | ||||
| define ( 'DB_UPDATE_VERSION',       1163  ); | ||||
|  | ||||
|  | ||||
| /** | ||||
|   | ||||
| @@ -1443,7 +1443,8 @@ function encode_item_meta($meta,$mirror = false) { | ||||
|  | ||||
| 	if($meta) { | ||||
| 		foreach($meta as $m) { | ||||
| 			$ret[] = array('family' => $m['cat'], 'key' => $m['k'], 'value' => $m['v']); | ||||
| 			if($m['sharing'] || $mirror) | ||||
| 				$ret[] = array('family' => $m['cat'], 'key' => $m['k'], 'value' => $m['v'], 'sharing' => intval($m['sharing'])); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -1455,7 +1456,7 @@ function decode_item_meta($meta) { | ||||
|  | ||||
| 	if(is_array($meta) && $meta) { | ||||
| 		foreach($meta as $m) { | ||||
| 			$ret[] = array('cat' => escape_tags($m['family']),'k' => escape_tags($m['key']),'v' => $m['value']); | ||||
| 			$ret[] = array('cat' => escape_tags($m['family']),'k' => escape_tags($m['key']),'v' => $m['value'],'sharing' => $m['sharing']); | ||||
| 		} | ||||
| 	} | ||||
| 	return $ret;		 | ||||
| @@ -2559,7 +2560,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { | ||||
|  | ||||
| 	if($meta) { | ||||
| 		foreach($meta as $m) { | ||||
| 			set_iconfig($current_post,$m['cat'],$m['k'],$m['v']); | ||||
| 			set_iconfig($current_post,$m['cat'],$m['k'],$m['v'],$m['sharing']); | ||||
| 		} | ||||
| 		$arr['iconfig'] = $meta; | ||||
| 	} | ||||
| @@ -2841,7 +2842,7 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) { | ||||
|  | ||||
| 	if($meta) { | ||||
| 		foreach($meta as $m) { | ||||
| 			set_iconfig($orig_post_id,$m['cat'],$m['k'],$m['v']); | ||||
| 			set_iconfig($orig_post_id,$m['cat'],$m['k'],$m['v'],$m['sharing']); | ||||
| 		} | ||||
| 		$arr['iconfig'] = $meta; | ||||
| 	} | ||||
| @@ -5504,7 +5505,7 @@ function get_iconfig(&$item, $family, $key) { | ||||
| } | ||||
|  | ||||
|  | ||||
| function set_iconfig(&$item, $family, $key, $value) { | ||||
| function set_iconfig(&$item, $family, $key, $value, $sharing = false) { | ||||
|  | ||||
| 	$dbvalue = ((is_array($value))  ? serialize($value) : $value); | ||||
| 	$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue)  : $dbvalue); | ||||
| @@ -5523,7 +5524,7 @@ function set_iconfig(&$item, $family, $key, $value) { | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		$entry = array('cat' => $family, 'k' => $key, 'v' => $value); | ||||
| 		$entry = array('cat' => $family, 'k' => $key, 'v' => $value, 'sharing' => $sharing); | ||||
|  | ||||
| 		if(is_null($idx)) | ||||
| 			$item['iconfig'][] = $entry; | ||||
| @@ -5539,16 +5540,18 @@ function set_iconfig(&$item, $family, $key, $value) { | ||||
| 		return false; | ||||
|  | ||||
| 	if(get_iconfig($item, $family, $key) === false) { | ||||
| 		$r = q("insert into iconfig( iid, cat, k, v ) values ( %d, '%s', '%s', '%s' ) ", | ||||
| 		$r = q("insert into iconfig( iid, cat, k, v, sharing ) values ( %d, '%s', '%s', '%s', %d ) ", | ||||
| 			intval($iid), | ||||
| 			dbesc($family), | ||||
| 			dbesc($key), | ||||
| 			dbesc($dbvalue) | ||||
| 			dbesc($dbvalue), | ||||
| 			intval($sharing) | ||||
| 		); | ||||
| 	} | ||||
| 	else { | ||||
| 		$r = q("update iconfig set v = '%s' where iid = %d and cat = '%s' and  k = '%s' ", | ||||
| 		$r = q("update iconfig set v = '%s', sharing = %d where iid = %d and cat = '%s' and  k = '%s' ", | ||||
| 			dbesc($dbvalue), | ||||
| 			intval($sharing), | ||||
| 			intval($iid), | ||||
| 			dbesc($family), | ||||
| 			dbesc($key) | ||||
|   | ||||
| @@ -550,10 +550,12 @@ CREATE TABLE IF NOT EXISTS `iconfig` ( | ||||
|   `cat` char(255) NOT NULL DEFAULT '', | ||||
|   `k` char(255) NOT NULL DEFAULT '', | ||||
|   `v` mediumtext NOT NULL, | ||||
|   `sharing` int(11) NOT NULL DEFAULT '0', | ||||
|   PRIMARY KEY (`id`), | ||||
|   KEY `iid` (`iid`), | ||||
|   KEY `cat` (`cat`), | ||||
|   KEY `k` (`k`) | ||||
|   KEY `k` (`k`), | ||||
|   KEY `sharing` (`sharing`), | ||||
| ) ENGINE=MyISAM  DEFAULT CHARSET=utf8; | ||||
|  | ||||
| CREATE TABLE IF NOT EXISTS `issue` ( | ||||
|   | ||||
| @@ -544,11 +544,13 @@ CREATE TABLE "iconfig" ( | ||||
|   "cat" text NOT NULL DEFAULT '', | ||||
|   "k" text NOT NULL DEFAULT '', | ||||
|   "v" text NOT NULL DEFAULT '', | ||||
|   "sharing" int NOT NULL DEFAULT '0', | ||||
|   PRIMARY_KEY("id") | ||||
| ); | ||||
| create index "iconfig_iid" on iconfig ("iid"); | ||||
| create index "iconfig_cat" on iconfig ("cat"); | ||||
| create index "iconfig_k" on iconfig ("k"); | ||||
| create index "iconfig_sharing" on iconfig ("sharing"); | ||||
| CREATE TABLE "issue" ( | ||||
|   "issue_id" serial  NOT NULL, | ||||
|   "issue_created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| <?php | ||||
|  | ||||
| define( 'UPDATE_VERSION' , 1162 ); | ||||
| define( 'UPDATE_VERSION' , 1163 ); | ||||
|  | ||||
| /** | ||||
|  * | ||||
| @@ -1971,7 +1971,6 @@ function update_r1161() { | ||||
| $r2 = q("create index \"iconfig_iid\" on iconfig (\"iid\") ");; | ||||
| $r3 = q("create index \"iconfig_cat\" on iconfig (\"cat\") "); | ||||
| $r4 = q("create index \"iconfig_k\" on iconfig (\"k\") "); | ||||
|  | ||||
| 	$r = $r1 && $r2 && $r3 && $r4; | ||||
| 	} | ||||
| 	else { | ||||
| @@ -1994,3 +1993,14 @@ $r4 = q("create index \"iconfig_k\" on iconfig (\"k\") "); | ||||
|     return UPDATE_FAILED; | ||||
| } | ||||
|  | ||||
| function update_r1162() { | ||||
| 	$r1 = q("alter table iconfig add sharing int not null default '0' "); | ||||
|  | ||||
| 	if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) | ||||
| 		$r2 = q("create index \"iconfig_sharing\" on iconfig (\"sharing\") ");  | ||||
| 	else  | ||||
| 		$r2 = q("alter table iconfig add index ( sharing ) "); | ||||
|     if($r1 && $r2) | ||||
|         return UPDATE_SUCCESS; | ||||
|     return UPDATE_FAILED; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user