예제 #1
0
 /**
  * Check the login data of a user and return true if data is correct or false if incorrect.
  * @param string Username
  * @param string User's pasword.
  * @return boolean true if check was successful or false if not.
  */
 function checkLogin($login, $passwd)
 {
     global $db, $c;
     $sql = "SELECT USER_ID FROM users WHERE USER_NAME='{$login}' AND PASSWORD = '******'";
     $query = new query($db, $sql);
     if ($query->count() == 1) {
         // login successfull
         $query->getrow();
         $this->userId = $query->field("USER_ID");
         return true;
     } else {
         return false;
     }
     $query->free();
 }
 /**
  * query the rows from the database
  */
 function getRows()
 {
     global $db, $c, $sid, $lang, $auth;
     $result = array();
     $order = "ca.TITLE";
     if ($this->order == "NAME") {
         $order = "ca.TITLE";
     } else {
         if ($this->order == "CATEGORY") {
             $order = "ca.CH_CAT_ID";
         } else {
             if ($this->order == "EDITED") {
                 $order = "cv.LAST_CHANGED";
             } else {
                 if ($this->order == "CREATED") {
                     $order = "cv.CREATED_AT";
                 } else {
                     if ($this->order == "POSITION") {
                         $order = "ca.POSITION";
                     }
                 }
             }
         }
     }
     $order .= " " . $this->orderdir;
     // $sql_articles = "Select ca.*, cv.LAST_USER, cv.CREATED_AT, cv.LAST_CHANGED FROM channel_articles ca, cluster_variations cv ".$this->getFilterJoin()." WHERE ca.CHID = ".$this->channelId." AND ca.ARTICLE_ID = cv.CLNID AND cv.VARIATION_ID = ".variation()." AND ca.VERSION=0 " . $this->getFilterSQL() . " ORDER BY $order LIMIT ".(($this->page - 1) * $this->recordsPerPage).",".$this->recordsPerPage;
     $sql_articles = "SELECT DISTINCT ca.* FROM channel_articles ca, cluster_variations cv " . $this->getFilterJoin() . " WHERE ca.ARTICLE_ID = cv.CLNID AND ca.CHID = " . $this->channelId . " AND ca.VERSION = 0 " . $this->getFilterSQL() . " ORDER BY {$order} LIMIT " . ($this->page - 1) * $this->recordsPerPage . "," . $this->recordsPerPage;
     // echo $sql_articles;
     $query = new query($db, $sql_articles);
     while ($query->getrow()) {
         $tmp = array();
         $varexists = true;
         $article_id = $query->field("ARTICLE_ID");
         $cvdatasql = "SELECT * FROM cluster_variations WHERE CLNID = " . $article_id . " AND VARIATION_ID=" . variation();
         $cvdata = new query($db, $cvdatasql);
         $cvdata->getrow();
         if ($cvdata->count() < 1) {
             $varexists = false;
         }
         array_push($tmp, $query->field("ARTICLE_ID"));
         $clid = getDBCell("cluster_variations", "CLID", "CLNID = " . $query->field("ARTICLE_ID") . " AND VARIATION_ID = " . variation());
         $live = isClusterLive($clid);
         if ($varexists) {
             if ($live) {
                 array_push($tmp, drawImage("green.gif", $lang->get("article_is_live", "Article is live")));
             } else {
                 array_push($tmp, drawImage("red.gif", $lang->get("article_is_expired", "Article is expired")));
             }
         } else {
             array_push($tmp, drawImage("gray.gif", $lang->get("article_variation_missing", "Variation of this article does not exist yet")));
         }
         array_push($tmp, $query->field("POSITION"));
         array_push($tmp, '<b>' . $query->field("TITLE") . '</b>');
         array_push($tmp, $this->categories[$query->field("CH_CAT_ID")]);
         array_push($tmp, formatDBTimestamp($cvdata->field("LAST_CHANGED")));
         $buttons = "&nbsp;" . crLink(drawImage('up.gif'), $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=up&article=" . $query->field("ARTICLE_ID"), "navelement");
         $buttons .= "&nbsp;" . crLink(drawImage('down.gif'), $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=down&article=" . $query->field("ARTICLE_ID"), "navelement");
         $buttons .= "&nbsp;";
         if ($auth->checkAccessToFunction("CHANNEL_DELETE")) {
             $buttons .= "&nbsp;" . crLink($lang->get("delete"), "javascript:confirmAction('" . $lang->get("del_article") . "', '" . $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=deletearticle&article=" . $query->field("ARTICLE_ID") . "');", "navelement");
         }
         if ($auth->checkAccessToFunction("CHANNEL_LAUNCH")) {
             $buttons .= "&nbsp;" . crLink($lang->get("launch", "Launch"), $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=launcharticle&article=" . $query->field("ARTICLE_ID"), "navelement");
             $buttons .= "&nbsp;" . crLink($lang->get("expire", "Expire"), $c["docroot"] . "modules/channels/overview.php?sid={$sid}&action=expirearticle&article=" . $query->field("ARTICLE_ID"), "navelement");
         }
         array_push($tmp, $buttons);
         array_push($result, $tmp);
     }
     return $result;
 }
예제 #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
/**
 * This function returns if a plugin is installed.
 * It's used, if a new plugin or a designed website require_onces a certain plugin.
 * @param 		string	The name of the desired plugin.
 * @returns		int		the version number if installed, otherwise false
 */
function is_plugin_installed($name)
{
    global $db;
    $sql = "SELECT VERSION FROM modules WHERE MODULE_NAME = '{$name}'";
    $query = new query($db, $sql);
    $amount = $query->count();
    if ($amount > 0) {
        $query->getrow();
        $version = $query->field("VERSION");
    }
    $query->free();
    return $amount > 0 ? $version : false;
}