Пример #1
0
 function canDelete(&$msg, $oid = null)
 {
     $tables[] = array('label' => 'Projects', 'name' => 'projects', 'idfield' => 'project_id', 'joinfield' => 'project_company');
     $tables[] = array('label' => 'Departments', 'name' => 'departments', 'idfield' => 'dept_id', 'joinfield' => 'dept_company');
     $tables[] = array('label' => 'Users', 'name' => 'users', 'idfield' => 'user_id', 'joinfield' => 'user_company');
     // call the parent class method to assign the oid
     return CDpObject::canDelete($msg, $oid, $tables);
 }
Пример #2
0
 function canDelete(&$msg, $oid = null, $joins = null)
 {
     global $AppUI;
     if ($oid) {
         // Check to see if there is a user
         $q = new DBQuery();
         $q->addTable('users');
         $q->addQuery('count(*) as user_count');
         $q->addWhere('user_contact = ' . (int) $oid);
         $user_count = $q->loadResult();
         if ($user_count > 0) {
             $msg = $AppUI->_('contactsDeleteUserError');
             return false;
         }
     }
     return parent::canDelete($msg, $oid, $joins);
 }
Пример #3
0
 function canDelete(&$msg, $oid = null, $joins = null)
 {
     global $AppUI;
     $oid = intval($oid ? $oid : $this->file_folder_id);
     if (!parent::canDelete($msg, $oid, $joins)) {
         return false;
     }
     $this->_query->clear();
     $this->_query->addTable($this->_tbl);
     $this->_query->addQuery('COUNT(DISTINCT file_folder_id) AS num_of_subfolders');
     $this->_query->addWhere('file_folder_parent=' . $oid);
     $sql1 = $this->_query->prepare();
     $this->_query->clear();
     $this->_query->addTable('files');
     $this->_query->addQuery('COUNT(DISTINCT file_id) AS num_of_files');
     $this->_query->addWhere('file_folder=' . $oid);
     $sql2 = $this->_query->prepare();
     $this->_query->clear();
     if (db_loadResult($sql1) > 0 || db_loadResult($sql2) > 0) {
         $msg = $AppUI->_('Can not delete folder, it has files and/or subfolders.');
         return false;
     }
     return true;
 }