Alias::GetAliases PHP Method

GetAliases() public static method

Get all the aliases that match the given criteria.
public static GetAliases ( integer $p_id = null, integer $p_publicationId = null, string $p_name = null ) : array
$p_id integer
$p_publicationId integer
$p_name string
return array
    public static function GetAliases($p_id = null, $p_publicationId = null, $p_name = null)
    {
        $contraints = array();
        if (!is_null($p_publicationId)) {
            $contraints[] = array("IdPublication", $p_publicationId);
        }
        if (!is_null($p_name)) {
            $contraints[] = array("Name", $p_name);
        }
        if (!is_null($p_id)) {
            $contraints[] = array("Id", $p_id);
        }
        return DatabaseObject::Search('Alias', $contraints);
    }

Usage Example

Example #1
0
/**
 * Check if the alias given is already in use.  If so, a user error message
 * is created.
 *
 * @param mixed $p_alias
 * 		Can be a string or an int.
 * @return void
 */
function camp_is_alias_conflicting($p_alias)
{
	global $ADMIN;

	if (!is_numeric($p_alias)) {
		// The alias given is a name, which means it doesnt exist yet.
		// Check if the name conflicts with any existing alias names.
		$aliases = Alias::GetAliases(null, null, $p_alias);
		$alias = array_pop($aliases);
		if ($alias) {
			$pubId = $alias->getPublicationId();
			$pubObj = new Publication($pubId);
			$pubLink = "<A HREF=\"/$ADMIN/pub/edit.php?Pub=$pubId\">". $pubObj->getName() ."</A>";
			$msg = getGS("The publication alias you specified conflicts with publication '$1'.", $pubLink);
			camp_html_add_msg($msg);
		}
	} else {
		// The alias given is a number, which means it already exists.
		// Check if the alias ID is already in use by another publication.
		$aliases = Alias::GetAliases($p_alias);
		$alias = array_pop($aliases);
		if ($alias) {
			$pubs = Publication::GetPublications(null, $alias->getId());
			if (count($pubs) > 0) {
				$pubObj = array_pop($pubs);
				$pubLink = "<A HREF=\"/$ADMIN/pub/edit.php?Pub=".$pubObj->getPublicationId().'">'. $pubObj->getName() ."</A>";
				$msg = getGS("The publication alias you specified conflicts with publication '$1'.", $pubLink);
				camp_html_add_msg($msg);
			}
		}
	}
}
All Usage Examples Of Alias::GetAliases