Beispiel #1
0
function GetFoldersAndFiles($resourceType, $currentFolder)
{
    if (!isset($_GET)) {
        global $_GET;
    }
    global $Config;
    $isInternalLink = isset($_GET['DWFCK_Browser']) && $_GET['DWFCK_Browser'] == 'local' ? true : false;
    global $_FolderClass;
    global $Config;
    $currentFolder = encode_dir($currentFolder);
    $sess_id = session_id();
    if (!isset($sess_id) || $sess_id != $_COOKIE['FCK_NmSp_acl']) {
        session_id($_COOKIE['FCK_NmSp_acl']);
        session_start();
    }
    $acl_del = isset($_SESSION['dwfck_del']) ? $_SESSION['dwfck_del'] : 0;
    // Map the virtual path to the local server path.
    $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'GetFoldersAndFiles');
    if ($Config['osWindows']) {
        $sServerDir = normalizeWIN($sServerDir);
    }
    mkdir_rek($sServerDir);
    // Arrays that will hold the folders and files names.
    $aFolders = array();
    $aFiles = array();
    $sFile = '__AAAAAAAA__.AAA';
    $temp_folder = $currentFolder;
    $temp_folder = dwiki_encodeFN(trim($temp_folder, '/'));
    has_permission($temp_folder, $resourceType);
    if ($isInternalLink && $_FolderClass < 16) {
        $sfclass = 'r';
    } else {
        if ($acl_del) {
            $sfclass = $_FolderClass >= 16 ? 'u' : 'r';
        } else {
            $sfclass = $_FolderClass >= 8 || has_open_access() ? 'u' : 'r';
        }
        can_delete($sfclass);
    }
    if (!$_FolderClass) {
        return;
    }
    $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" class="' . $sfclass . '" />';
    $sErrorNumber = 0;
    $sFolderPath = GetResourceTypeDirectory($resourceType, 'GetFoldersAndFiles');
    $absolute_path = $Config['UserFilesAbsolutePath'];
    $oCurrentFolder = @opendir($sServerDir);
    if ($oCurrentFolder !== false) {
        while ($sFile = readdir($oCurrentFolder)) {
            if ($sFile != '.' && $sFile != '..') {
                if (is_dir($sServerDir . $sFile)) {
                    if (has_permission(dwiki_encodeFN($currentFolder) . $sFile, $resourceType) || has_open_access()) {
                        if ($isInternalLink && $_FolderClass < 255) {
                            $class = 'r';
                        } else {
                            $class = $_FolderClass < 8 ? 'r' : 'u';
                            can_delete($class);
                        }
                        if ($_FolderClass) {
                            $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" class="' . $class . '" />';
                        }
                    }
                } else {
                    $iFileSize = @filesize($sServerDir . $sFile);
                    if (!$iFileSize) {
                        $iFileSize = 0;
                    }
                    if ($iFileSize > 0) {
                        $iFileSize = round($iFileSize / 1024);
                        if ($iFileSize < 1) {
                            $iFileSize = 1;
                        }
                    }
                    if ($isInternalLink) {
                        if (!preg_match('/\\.txt$/', $sFile)) {
                            continue;
                        }
                        if (has_permission(dwiki_encodeFN($currentFolder) . $sFile, $resourceType, false)) {
                            $aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />';
                        }
                    } else {
                        if ($resourceType == 'Image') {
                            list($width, $height, $type, $attr) = getimagesize($sServerDir . $sFile);
                            if (isset($width) && isset($height)) {
                                $iFileSize .= ";;{$width};;{$height}";
                            }
                        }
                        $aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />';
                    }
                }
            }
        }
        closedir($oCurrentFolder);
    }
    // Send the folders
    natcasesort($aFolders);
    echo '<Folders>';
    foreach ($aFolders as $sFolder) {
        echo $sFolder;
    }
    echo '</Folders>';
    // Send the files
    natcasesort($aFiles);
    echo '<Files>';
    foreach ($aFiles as $sFiles) {
        echo $sFiles;
    }
    echo '</Files>';
}
 /**
  * Check if specific user can delete this contact
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canDelete(User $user)
 {
     return can_manage_contacts($user, true) || can_delete($user, $this);
 }
 /**
  * Check if specific user can delete this contact
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canDelete(Contact $user)
 {
     // dont delete account owner
     if ($this->isAccountOwner() || $this->isOwnerCompany()) {
         return false;
     }
     if ($this->getUserType() != 0) {
         return can_manage_security($user) && $this->getUserType() > $user->getUserType();
     } else {
         return can_manage_contacts($user) || can_delete($user, $this->getMembers(), $this->getObjectTypeId());
     }
 }
 /**
  * Returns true if $user can delete this email
  *
  * @param User $user
  * @return boolean
  */
 function canDelete(User $user)
 {
     return can_delete($user, $this);
     //		return $this->getAccount()->getUserId() == $user->getId() || $user->isAdministrator();
 }
Beispiel #5
0
    if ($myrow[0] > 0) {
        display_error(tr('Cannot delete this item record because there are ' . 'existing sales orders for this part.'));
        return false;
    }
    $sql = "SELECT COUNT(*) FROM purch_order_details " . "WHERE item_code='{$stock_id}'";
    $result = db_query($sql, "could not query purchase orders");
    $myrow = db_fetch_row($result);
    if ($myrow[0] > 0) {
        display_error(tr('Cannot delete this item because there are existing ' . 'purchase order items for it.'));
        return false;
    }
    return true;
}
//------------------------------------------------------------------------------------
if (isset($_POST['delete']) && strlen($_POST['delete']) > 1) {
    if (can_delete($_POST['NewStockID'])) {
        $stock_id = $_POST['NewStockID'];
        delete_item($stock_id);
        meta_forward($_SERVER['PHP_SELF']);
    }
}
//------------------------------------------------------------------------------------
start_form(true);
if (db_has_stock_items()) {
    start_table("class='tablestyle_noborder'");
    start_row();
    stock_items_list_cells(tr("Select an item:"), 'stock_id', null, null, null, null, 1);
    submit_cells('SelectStockItem', tr("Edit Item"));
    end_row();
    end_table();
}
	/**
	 * Returns true if $user can delete this email
	 *
	 * @param Contact $user
	 * @return boolean
	 */
	function canDelete(Contact $user) {
		$account = $this->getAccount();
		if ($account) {
			return ( 
				$account->getContactId() == logged_user()->getId() || 
				can_delete($user,$this->getMembers(), $this->getObjectTypeId())
			);	
		}else{
			return can_delete($user, $this->getMembers(), $this->getObjectTypeId());
		}
	}
Beispiel #7
0
 function masstrash($table)
 {
     checklogin();
     if (!can_delete($table)) {
         redirect(base_url() . 'content/' . $table . '/:error:' . urlencode('Sorry. You do not have permissions to delete things from ' . humanizer($table)));
         exit;
     }
     if (!$_POST || !$_POST['ids']) {
         redirect(base_url() . 'content/' . $table);
         exit;
     }
     $table = mysql_real_escape_string($table);
     foreach ($_POST['ids'] as $id) {
         $id = mysql_real_escape_string($id);
         $this->db->query("UPDATE {$table} SET __is_trash=1 WHERE id='{$id}'");
         //$this->memcached_library->flush();
     }
     redirect(base_url() . 'content/' . $table . '/:success:' . urlencode('Items have been moved to trash.'));
 }
 /**
  * Check if specific user can delete this task
  *
  * @access public
  * @param Contact $user
  * @return boolean
  */
 function canDelete(Contact $user)
 {
     if (can_delete($user, $this->getMembers(), $this->getObjectTypeId())) {
         return true;
     }
     $task_list = $this->getParent();
     return $task_list instanceof TemplateTask ? $task_list->canDelete($user) : false;
 }
 function delete_timeslot()
 {
     if (!can_delete(logged_user(), active_context(), Timeslots::instance()->getObjectTypeId())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $timeslot = Timeslots::findById(get_id());
     if (!$timeslot instanceof Timeslot) {
         flash_error(lang('timeslot dnx'));
         return;
     }
     if (!$timeslot->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         return;
     }
     try {
         DB::beginWork();
         $timeslot->delete();
         DB::commit();
         ajx_extra_data(array("timeslotId" => get_id()));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
     // try
 }
Beispiel #10
0
        display_error(_("Cannot delete this account because it is used by one or more Customer Branches."));
        return false;
    }
    if (gl_account_in_suppliers($selected_account)) {
        display_error(_("Cannot delete this account because it is used by one or more suppliers."));
        return false;
    }
    if (gl_account_in_quick_entry_lines($selected_account)) {
        display_error(_("Cannot delete this account because it is used by one or more Quick Entry Lines."));
        return false;
    }
    return true;
}
//--------------------------------------------------------------------------------------
if (isset($_POST['delete'])) {
    if (can_delete($selected_account)) {
        delete_gl_account($selected_account);
        $selected_account = $_POST['AccountList'] = '';
        delete_tag_associations(TAG_ACCOUNT, $selected_account, true);
        $selected_account = $_POST['AccountList'] = '';
        display_notification(_("Selected account has been deleted"));
        unset($_POST['account_code']);
        $Ajax->activate('_page_body');
    }
}
//-------------------------------------------------------------------------------------
start_form();
if (db_has_gl_accounts()) {
    start_table(TABLESTYLE_NOBORDER);
    start_row();
    gl_all_accounts_list_cells(null, 'AccountList', null, false, false, _('New account'), true, check_value('show_inactive'));
 /**
  * Check if specific user can delete this milestone
  *
  * @access public
  * @param Contact $contact
  * @return boolean
  */
 function canDelete(Contact $contact)
 {
     return can_delete($contact, $this->getMembers(), $this->getObjectTypeId());
 }
 /**
  * Check if specific user can delete this comment
  *
  * @access public
  * @param Contact $user
  * @return boolean
  */
 function canDelete(Contact $user)
 {
     if ($this->isCheckedOut() && $this->getCheckedOutById() != $user->getId()) {
         return false;
     }
     return can_delete($user, $this->getMembers(), $this->getObjectTypeId());
 }
	/**
	 * Empty implementation of static method. Update tag permissions are check by the taggable
	 * object, not tag itself
	 *
	 * @param User $user
	 * @return boolean
	 */
	function canDelete(Contact $user) {
		return can_delete($user,$this);
	} // canDelete
 /**
  * Returns true if $user can delete this email
  *
  * @param Contact $user
  * @return boolean
  */
 function canDelete(Contact $user)
 {
     $account = $this->getAccount();
     $members = $this->getMembers();
     $persons_dim = Dimensions::findByCode('feng_persons');
     $tmp = array();
     foreach ($members as $m) {
         if (!$persons_dim instanceof Dimension || $m->getDimensionId() != $persons_dim->getId()) {
             $tmp[] = $m;
         }
     }
     $members = $tmp;
     if ($account instanceof MailAccount) {
         // if classified
         if (count($members) > 0) {
             return $account->getContactId() == logged_user()->getId() || can_delete($user, $members, $this->getObjectTypeId());
         } else {
             $macs = MailAccountContacts::instance()->count(array('`account_id` = ? AND `contact_id` = ? AND `can_edit` = 1', $account->getId(), $user->getId()));
             return $account->getContactId() == logged_user()->getId() || $macs > 0;
         }
     } else {
         // if classified
         return can_delete($user, $members, $this->getObjectTypeId());
     }
 }
Beispiel #15
0
 /**
  * Check if specific user can delete this report
  *
  * @access public
  * @param Contact $user
  * @return boolean
  */
 function canDelete(Contact $user)
 {
     return can_delete($user, $this->getMembers(), $this->manager()->getObjectTypeId());
 }
Beispiel #16
0
 /**
  * Empty implementation of static method. Update tag permissions are check by the taggable
  * object, not tag itself
  *
  * @param Contact $user
  * @return boolean
  */
 function canDelete(Contact $user)
 {
     $object = $this->getRelObject();
     return can_delete($user, $object->getMembers(), $object->getObjectTypeId());
 }
    if ($type == "") {
        return false;
    }
    if (key_in_foreign_table($type, 'chart_master', 'account_type')) {
        display_error(_("Cannot delete this account group because GL accounts have been created referring to it."));
        return false;
    }
    if (key_in_foreign_table($type, 'chart_types', 'parent')) {
        display_error(_("Cannot delete this account group because GL account groups have been created referring to it."));
        return false;
    }
    return true;
}
//-----------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    if (can_delete($selected_id)) {
        delete_account_type($selected_id);
        display_notification(_('Selected account group has been deleted'));
    }
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = "";
    $_POST['id'] = $_POST['name'] = '';
    unset($_POST['parent']);
    unset($_POST['class_id']);
}
//-----------------------------------------------------------------------------------
$result = get_account_types(check_value('show_inactive'));
start_form();
start_table(TABLESTYLE);
Beispiel #18
0
	/**
	 * Empty implementation of static method. Update tag permissions are check by the taggable
	 * object, not tag itself
	 *
	 * @param Contact $user
	 * @return boolean
	 */
	function canDelete(Contact $user) {
		$object = $this->getRelObject();
		if (!$object instanceof ContentDataObject) {
			return false;
		}
		return can_delete($user, $object->getMembers(), $object->getObjectTypeId());
	} // canDelete
 /**
  * Check if specific user can delete this comment
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canDelete(User $user)
 {
     return can_delete($user, $this);
 }
 /**
  * Check if specific user can delete this task
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canDelete(User $user)
 {
     if (can_delete($user, $this)) {
         return true;
     }
     $task_list = $this->getParent();
     return $task_list instanceof ProjectTask ? $task_list->canDelete($user) : false;
 }