示例#1
0
/**
 * Creates an Article out of a page
 * @param integer $spid ID of the sitepage
 * @param integer $channel ID of the channel
 * @param $category ID of the Channelcategory
 */
function importClusterToArticle($spid, $channel, $category)
{
    $clnid = getDBCell("sitepage", "CLNID", "SPID=" . $spid);
    $menues = createNameValueArrayEx("sitepage_names", "NAME", "VARIATION_ID", "SPID=" . $spid, "ORDER BY VARIATION_ID ASC");
    $clt = getDBCell("cluster_node", "CLT_ID", "CLNID=" . $clnid);
    $cs = new CreateSet("channel_articles");
    $cs->add("ARTICLE_ID", $clnid, "NUMBER");
    $cs->add("CHID", $channel, "NUMBER");
    $cs->add("CH_CAT_ID", $category, "NUMBER");
    $cs->add("VERSION", "0", "NUMBER");
    $cs->add("CLT_ID", $clt, "NUMBER");
    $cs->add("TITLE", $menues[0][0], "TEXT");
    $cs->add("POSITION", 999, "NUMBER");
    $cs->execute();
    processSaveSets();
}
		/**
		 * Does nothing here. process must be done my developer.
		 */
		function process() {
			global $page_state;

			if ($page_state == "processing") {
				$nextIndex = count($this->keys);

				deleteRow($this->table, $this->row_identifier);

				if (is_array($this->properties)) {
					foreach ($this->properties as $key => $value) {
						foreach ($value as $role) {
							$is = $this->keys;

							$is[$nextIndex][0] = $this->column2;
							$is[$nextIndex][1] = $role;
							$is[$nextIndex][2] = $this->column2_dt;

							$is[$nextIndex + 1][0] = $this->column1;
							$is[$nextIndex + 1][1] = $key;
							$is[$nextIndex + 1][2] = $this->column1_dt;

							$cs = new CreateSet($this->table);

							for ($i = 0; $i < count($is); $i++) {
								$cs->add($is[$i][0], $is[$i][1], $is[$i][2]);
							}

							$cs->execute();
						}
					}
				}
			}
		}
示例#3
0
	/**
	 * Copies a row an replaces specified values
	 * if translate is specified as value, the given id will be translated to a live id.
	 *
	 * @param string Name of table in which row shall be copied
	 * @param string Filter to apply on table to select record(s)
	 * @param array array[n]["column"]: Column to replace, array[n]["value"]: Value to set, array[n]["datatype"]: type of data (NUMBER|CHAR|DATE)
	 */
	function copyRow($table, $filter, $values) {
		global $db, $c_datatypes, $panic;		
		$sql = "SELECT * FROM $table WHERE $filter";
		$query = new query($db, $sql);

		for ($i = 0; $i < $query->count(); $i++) {
			$row = $query->getrow();

			$newRec = new CreateSet($table);

			$columns = $db->ADODB->MetaColumns($table);
			if (!is_array($columns)) return false;
			foreach ($columns as $name=>$obvalue) {
				$value[$n] = $query->field($name);
				foreach ($values as $vcol => $vval) {
					if ($name == $vcol) {
						if (sameText($vval, "translate")) {
							if (is_numeric($value[$n]) && ($value[$n] != "0"))
							  $value[$n] = translateState($value[$n], 10, false);
						} else {
						  $value[$n] = $vval;
						}
					}
				}
				$column[$n] = $name;
				$newRec->add($column[$n], $value[$n], $c_datatypes[$table][$name]);
			}
			$newRec->execute();			
		}		
	}
示例#4
0
		/**
		   * Syncs an ACLObject. Compare to sync, but does not write accessors.
		   */
		function syncEx() {
			if (countRows("acl_management", "GUID", "GUID = " . $this->guid) < 1) {
				$crs = new CreateSet("acl_management");

				$crs->add("GUID", $this->guid, "NUMBER");
				$crs->add("TYPE_ID", $this->typeId, "NUMBER");
				$crs->execute();
			}

			// now save the data...
			$this->saveEx();
		}
示例#5
0
		/**
		   * Write a log entry to the database
		   * @access private
		   */
		function writeLog() {
			global $db;

			$logId = $db->nextid("log");
			$cr = new CreateSet("log");
			$cr->add("LOG_ID", $logId, "NUMBER");
			$cr->add("CATEGORY", $this->category, "TEXT");
			$cr->add("MESSAGE", $this->message, "TEXT");

			if ($this->system) {
				$cr->add("USER_ID", 0, "NUMBER");
			} else {
				$cr->add("USER_ID", $this->userId, "NUMBER");
			}

			if ($this->target1 != 0) {
				$cr->add("TARGET1_ID", $this->target1, "NUMBER");
			}

			if ($this->target2 != 0) {
				$cr->add("TARGET2_ID", $this->target2, "NUMBER");
			}

			$cr->execute();
			unset ($cr);
		}