public function do_add() { extract($this->getHelperObjects()); Loader::model('file_set'); if (!$validation_token->validate("file_sets_add")) { $this->set('error', array($validation_token->getErrorMessage())); return; } if (!trim($this->post('file_set_name'))) { $this->set('error', array(t('Please Enter a Name'))); return; } $setName = trim($this->post('file_set_name')); if (preg_match('/[<>;{}?"`]/i', $setName)) { $this->set('error', array(t('File Set Name cannot contain the characters: %s', Loader::helper('text')->entities('<>;{}?"`')))); return; } //print('<pre>');print_r(get_included_files());print('</pre>'); $u = new User(); $file_set = new FileSet(); //AS: Adodb Active record is complaining a ?/value array mismatch unless //we explicatly set the primary key ID field to null $file_set->fsID = null; $file_set->fsName = $setName; $file_set->fsType = FileSet::TYPE_PUBLIC; $file_set->uID = $u->getUserID(); $file_set->fsOverrideGlobalPermissions = $this->post('fsOverrideGlobalPermissions') == 1 ? 1 : 0; $file_set->save(); $this->redirect('/dashboard/files/sets', 'file_set_added'); }
/** * Creats a new fileset if set doesn't exists * * If we find a multiple groups with the same properties, * we return an array containing each group * @param string $fs_name * @param int $fs_type * @param int $fs_uid * @return Mixed * * Dev Note: This will create duplicate sets with the same name if a set exists owned by another user!!! */ public static function createAndGetSet($fs_name, $fs_type, $fs_uid=false) { if (!$fs_uid) { $u = new User(); $fs_uid = $u->uID; } $file_set = new FileSet(); $criteria = array($fs_name,$fs_type,$fs_uid); $matched_sets = $file_set->Find('fsName=? AND fsType=? and uID=?',$criteria); if (1 === count($matched_sets) ) { return $matched_sets[0]; } else if (1 < count($matched_sets)) { return $matched_sets; } else{ //AS: Adodb Active record is complaining a ?/value array mismatch unless //we explicatly set the primary key ID field to null $file_set->fsID = null; $file_set->fsName = $fs_name; $file_set->fsOverrideGlobalPermissions = 0; $file_set->fsType = $fs_type; $file_set->uID = $fs_uid; $file_set->save(); return $file_set; } }
public function file_sets_edit() { extract($this->getHelperObjects()); Loader::model('file_set'); //do my editing if (!$validation_token->validate("file_sets_edit")) { $this->set('error', array($validation_token->getErrorMessage())); $this->view(); return; } if (!$this->post('fsID')) { $this->set('error', array(t('Invalid ID'))); $this->view(); } $file_set = new FileSet(); $file_set->Load('fsID = ?', $this->post('fsID')); $file_set->fsName = $this->post('file_set_name'); $file_set->fsOverrideGlobalPermissions = $this->post('fsOverrideGlobalPermissions') == 1 ? 1 : 0; $file_set->save(); $file_set->resetPermissions(); if ($file_set->fsOverrideGlobalPermissions == 1) { $p = $this->post(); $fh = Loader::controller('/dashboard/files/access'); $fh->setFileSetPermissions($file_set, $p); } $this->set('message', t('Changes Saved')); $this->view(); }