Beispiel #1
0
 /**
  * Creates a new asset in the database
  * 
  * @param int|string $folder Folder ID or String (/Workspace/.../)
  * @param string $view View name (e.g. display, details)
  * @param array $data Associative Array containing one asset 
  * @return array|int succes: numeric ID, error: array( field_name => array( array( field_displayname, message ), ... ) ) 
  */
 static function asset_insert($folder, $view, array $data)
 {
     self::_require_access($folder, "write", $view);
     $sgsml = new sgsml($folder, $view);
     if ($sgsml->current_view["SCHEMA_MODE"] != "new") {
         exit("{t}Access denied.{/t} " . sprintf("{t}Invalid schema mode '%s'{/t}", $sgsml->current_view["SCHEMA_MODE"]));
     }
     return $sgsml->insert($data);
 }
Beispiel #2
0
 static function create_user($username, $data = array())
 {
     $data["username"] = $username;
     $data["createdby"] = "auth_" . SETUP_AUTH;
     if (empty($data["password"])) {
         $data["password"] = "******";
     }
     if (empty($data["email"])) {
         $data["email"] = $username;
     }
     if (!strpos($data["email"], "@")) {
         $data["email"] .= "@invalid.local";
     }
     if (empty($_SESSION["username"])) {
         $_SESSION["username"] = "******";
         $_SESSION["permission_sql"] = "1=1";
         $_SESSION["permission_sql_read"] = "1=1";
         $_SESSION["groups"] = array();
     }
     $row_id = db_select_value("simple_sys_users", "id", "username=@username@", array("username" => $username));
     if (!empty($row_id)) {
         return;
     }
     $row = db_select_first("simple_sys_tree", "id", "ftype=@ftype@", "lft asc", array("ftype" => "sys_users"));
     if (empty($row["id"])) {
         return;
     }
     $sgsml = new sgsml($row["id"], "new");
     $result = $sgsml->insert($data);
     if (is_numeric($result)) {
         trigger::addgroupmember(0, array("username" => $username), array("users_self_registration"));
         sys_notification("{t}Item successfully created.{/t} (" . $result . ")");
     } else {
         if (is_array($result) and count($result) > 0) {
             $message = array();
             foreach ($result as $errors) {
                 foreach ($errors as $error) {
                     $message[] = $error[0] . ": " . $error[1];
                 }
             }
             sys_log_message_alert("login", implode("\n", $message));
         }
     }
 }
Beispiel #3
0
 private static function _create_default_folder_xml_data($xml, $folder)
 {
     $assets = sys_array_shift(get_object_vars($xml));
     if (is_object($assets)) {
         $assets = array($assets);
     }
     if (!is_array($assets) or count($assets) == 0) {
         return;
     }
     @set_time_limit(60);
     $sgsml = new sgsml($folder, "new");
     $sgsml->notification = false;
     foreach ($assets as $asset) {
         $data = get_object_vars($asset);
         if (isset($data["@attributes"])) {
             unset($data["@attributes"]);
         }
         $result = $sgsml->insert($data);
         if (DEBUG and !is_int($result)) {
             print_r($result);
         }
         if (DEBUG) {
             echo " @" . memory_get_usage(true);
         }
         sys::$cache = array();
         sys::$db_queries = array();
     }
 }