示例#1
0
文件: file.php 项目: notzen/concrete5
	public function duplicate() {
		$dh = Loader::helper('date');
		$db = Loader::db();
		$date = $dh->getSystemDateTime(); 

		$far = new ADODB_Active_Record('Files');
		$far->Load('fID=?', array($this->fID));
		
		$far2 = clone $far;
		$far2->fID = null;
		$far2->fDateAdded = $date;
		$far2->Insert();
		$fIDNew = $db->Insert_ID();

		$fvIDs = $db->GetCol('select fvID from FileVersions where fID = ?', $this->fID);
		foreach($fvIDs as $fvID) {
			$farv = new ADODB_Active_Record('FileVersions');
			$farv->Load('fID=? and fvID = ?', array($this->fID, $fvID));
	
			$farv2 = clone $farv;
			$farv2->fID = $fIDNew;
			$farv2->fvActivateDatetime = $date;
			$farv2->fvDateAdded = $date;
			$farv2->Insert();
		}		

		$r = $db->Execute('select fvID, akID, avID from FileAttributeValues where fID = ?', array($this->getFileID()));
		while ($row = $r->fetchRow()) {
			$db->Execute("insert into FileAttributeValues (fID, fvID, akID, avID) values (?, ?, ?, ?)", array(
				$fIDNew, 
				$row['fvID'],
				$row['akID'], 
				$row['avID']
			));
		}
		
		// return the new file object
		return File::getByID($fIDNew);
		
	}
示例#2
0
 /** 
  * Duplicates an attribute key 
  */
 public function duplicate($args = array())
 {
     $ar = new ADODB_Active_Record('AttributeKeys');
     $ar->Load('akID=?', array($this->akID));
     $ar2 = clone $ar;
     $ar2->akID = null;
     foreach ($args as $key => $value) {
         $ar2->{$key} = $value;
     }
     $ar2->Insert();
     $db = Loader::db();
     $ak = new AttributeKey();
     $ak->load($db->Insert_ID());
     // now we duplicate the specific category fields
     $this->getController()->duplicateKey($ak);
     return $ak;
 }
 public function editar()
 {
     //Modificar carpetas vistas
     $this->usarScaffold();
     //Conectarse a la base de datos
     if ($this->db == "") {
         $this->db = "default";
     }
     $conexion = $this->nucleo->getConexion($this->db);
     $conexion->Execute("SET NAMES utf8");
     //Obtenemos las llaves primarias
     $columnas = $conexion->MetaColumns($this->modelo);
     $where = "";
     foreach ($columnas as $c) {
         if ($c->primary_key == 1) {
             if ($where != "") {
                 $where .= " AND ";
             }
             $where .= $c->name . "='" . $this->par[$c->name] . "'";
         }
     }
     $modelo = new ADODB_Active_Record($this->modelo);
     $modelo->Load($where);
     $campos = $this->getCampos($modelo);
     $this->set("accion", "editarRegistro");
     $this->set("vista", "agregar");
     //Asignar campos
     $this->set("campos", $campos);
     //Asignar prefijo ID
     $prefijo = "id" . date("is") . rand();
     $this->set("id_prefijo", $prefijo);
     //Edicion adicional
     foreach ($campos as $c) {
         if ($c["primaria"] == 1) {
             $par .= "&" . $c["nombre"] . "=" . $c["valor"];
         }
     }
     $par .= "&prefijo=" . $prefijo;
     $this->set("parametros", $par);
     $this->set("editar_adicional", $this->editar_adicional);
 }