示例#1
0
 /**
  * Set related list information between other module
  * @param Vtiger_Module Instance of target module with which relation should be setup
  * @param String Label to display in related list (default is target module name)
  * @param Array List of action button to show ('ADD', 'SELECT')
  * @param String Callback function name of this module to use as handler
  *
  * @internal Creates table vtiger_crmentityrel if it does not exists
  */
 function setRelatedList($moduleInstance, $label = '', $actions = false, $function_name = 'get_related_list')
 {
     global $adb;
     if (empty($moduleInstance)) {
         return;
     }
     if (!Vtiger_Utils::CheckTable('vtiger_crmentityrel')) {
         Vtiger_Utils::CreateTable('vtiger_crmentityrel', '(crmid INT NOT NULL, module VARCHAR(100) NOT NULL, relcrmid INT NOT NULL, relmodule VARCHAR(100) NOT NULL)', true);
     }
     $relation_id = $this->__getRelatedListUniqueId();
     $sequence = $this->__getNextRelatedListSequence();
     $presence = 0;
     // 0 - Enabled, 1 - Disabled
     if (empty($label)) {
         $label = $moduleInstance->name;
     }
     // Allow ADD action of other module records (default)
     if ($actions === false) {
         $actions = array('ADD');
     }
     $useactions_text = $actions;
     if (is_array($actions)) {
         $useactions_text = implode(',', $actions);
     }
     $useactions_text = strtoupper($useactions_text);
     // Add column to vtiger_relatedlists to save extended actions
     Vtiger_Utils::AddColumn('vtiger_relatedlists', 'actions', 'VARCHAR(50)');
     $adb->pquery("INSERT INTO vtiger_relatedlists(relation_id,tabid,related_tabid,name,sequence,label,presence,actions) VALUES(?,?,?,?,?,?,?,?)", array($relation_id, $this->id, $moduleInstance->id, $function_name, $sequence, $label, $presence, $useactions_text));
     self::log("Setting relation with {$moduleInstance->name} [{$useactions_text}] ... DONE");
 }
示例#2
0
 /**
  * Set related list information between other module
  * @param Vtiger_Module Instance of target module with which relation should be setup
  * @param String Label to display in related list (default is target module name)
  * @param Array List of action button to show ('ADD', 'SELECT')
  * @param String Callback function name of this module to use as handler
  *
  * @internal Creates table vtiger_crmentityrel if it does not exists
  */
 function setRelatedList($moduleInstance, $label = '', $actions = false, $functionName = 'get_related_list')
 {
     $adb = PearDatabase::getInstance();
     if (empty($moduleInstance)) {
         return;
     }
     if (empty($label)) {
         $label = $moduleInstance->name;
     }
     $result = $adb->pquery('SELECT relation_id FROM vtiger_relatedlists WHERE tabid=? AND related_tabid = ? AND name = ? AND label = ?;', [$this->id, $moduleInstance->id, $functionName, $label]);
     if ($result->rowCount() > 0) {
         self::log("Setting relation with {$moduleInstance->name} [{$useactions_text}] ... Error, the related module already exists");
         return;
     }
     $sequence = $this->__getNextRelatedListSequence();
     $presence = 0;
     // 0 - Enabled, 1 - Disabled
     // Allow ADD action of other module records (default)
     if ($actions === false) {
         $actions = ['ADD'];
     }
     $useactionsText = $actions;
     if (is_array($actions)) {
         $useactionsText = implode(',', $actions);
     }
     $useactionsText = strtoupper($useactionsText);
     $adb->insert('vtiger_relatedlists', ['relation_id' => $adb->getUniqueID('vtiger_relatedlists'), 'tabid' => $this->id, 'related_tabid' => $moduleInstance->id, 'name' => $functionName, 'sequence' => $sequence, 'label' => $label, 'presence' => $presence, 'actions' => $useactionsText]);
     if ($functionName == 'get_many_to_many') {
         $refTableName = Vtiger_Relation_Model::getReferenceTableInfo($moduleInstance->name, $this->name);
         if (!Vtiger_Utils::CheckTable($refTableName['table'])) {
             Vtiger_Utils::CreateTable($refTableName['table'], '(crmid INT(19) ,relcrmid INT(19),KEY crmid (crmid),KEY relcrmid (relcrmid))', true);
         }
     }
     self::log("Setting relation with {$moduleInstance->name} [{$useactions_text}] ... DONE");
 }
示例#3
0
    function undo($moduleName, $userId)
    {
        $adb = PearDatabase::getInstance();
        if (Vtiger_Utils::CheckTable($this->tableName)) {
            $result = $adb->pquery('UPDATE vtiger_crmentity SET deleted=1 WHERE crmid IN
								(SELECT crmid FROM ' . $this->tableName . ' WHERE userid = ? AND entitytype = ?)', array($userId, $moduleName));
            return $adb->getAffectedRowCount($result);
        }
    }
示例#4
0
 public function delete()
 {
     $adb = PearDatabase::getInstance();
     parent::delete();
     $fld_module = $this->getModuleName();
     $id = $this->getId();
     $uitype = $this->get('uitype');
     $typeofdata = $this->get('typeofdata');
     $fieldname = $this->getName();
     $oldfieldlabel = $this->get('label');
     $tablename = $this->get('table');
     $columnname = $this->get('column');
     $fieldtype = explode("~", $typeofdata);
     $tabId = $this->getModuleId();
     $focus = CRMEntity::getInstance($fld_module);
     $deletecolumnname = $tablename . ":" . $columnname . ":" . $fieldname . ":" . $fld_module . "_" . str_replace(" ", "_", $oldfieldlabel) . ":" . $fieldtype[0];
     $column_cvstdfilter = $tablename . ":" . $columnname . ":" . $fieldname . ":" . $fld_module . "_" . str_replace(" ", "_", $oldfieldlabel);
     $select_columnname = $tablename . ":" . $columnname . ":" . $fld_module . "_" . str_replace(" ", "_", $oldfieldlabel) . ":" . $fieldname . ":" . $fieldtype[0];
     $reportsummary_column = $tablename . ":" . $columnname . ":" . str_replace(" ", "_", $oldfieldlabel);
     if ($tablename != 'vtiger_crmentity') {
         $dbquery = 'alter table ' . $adb->quote($tablename, false) . ' drop column ' . $adb->quote($columnname, false);
         $adb->pquery($dbquery, array());
     }
     //we have to remove the entries in customview and report related tables which have this field ($colName)
     $adb->pquery('delete from vtiger_cvcolumnlist where columnname = ? ', array($deletecolumnname));
     $adb->pquery('delete from vtiger_cvstdfilter where columnname = ?', array($column_cvstdfilter));
     $adb->pquery('delete from vtiger_cvadvfilter where columnname = ?', array($deletecolumnname));
     $adb->pquery('delete from vtiger_selectcolumn where columnname = ?', array($select_columnname));
     $adb->pquery('delete from vtiger_relcriteria where columnname = ?', array($select_columnname));
     $adb->pquery('delete from vtiger_reportsortcol where columnname = ?', array($select_columnname));
     $adb->pquery('delete from vtiger_reportdatefilter where datecolumnname = ?', array($column_cvstdfilter));
     $adb->pquery('delete from vtiger_reportsummary where columnname like ?', array('%' . $reportsummary_column . '%'));
     //Deleting from convert lead mapping vtiger_table- Jaguar
     if ($fld_module == 'Leads') {
         $deletequery = 'delete from vtiger_convertleadmapping where leadfid=?';
         $adb->pquery($deletequery, array($id));
     } elseif ($fld_module == 'Accounts' || $fld_module == 'Contacts') {
         $map_del_id = array('Accounts' => 'accountfid', 'Contacts' => 'contactfid');
         $map_del_q = 'update vtiger_convertleadmapping set ' . $map_del_id[$fld_module] . '=0 where ' . $map_del_id[$fld_module] . '=?';
         $adb->pquery($map_del_q, array($id));
     }
     //HANDLE HERE - we have to remove the table for other picklist type values which are text area and multiselect combo box
     if ($this->getFieldDataType() == 'picklist' || $this->getFieldDataType() == 'multipicklist') {
         $result = $adb->pquery('SELECT * FROM `vtiger_field` WHERE `columnname` = ? AND `uitype` IN (?,?,?);', [$columnname, 15, 16, 33]);
         if (!$adb->num_rows($result)) {
             $adb->query('drop table vtiger_' . $columnname);
             //To Delete Sequence Table
             if (Vtiger_Utils::CheckTable('vtiger_' . $columnname . '_seq')) {
                 $adb->query('drop table vtiger_' . $columnname . '_seq');
             }
             $adb->pquery('delete from vtiger_picklist where name=? ', array($columnname));
         }
         $adb->pquery('delete from vtiger_picklist_dependency where `tabid` = ? AND (sourcefield=? or targetfield=?)', array($tabId, $columnname, $columnname));
     }
 }
示例#5
0
文件: Link.php 项目: mslokhat/corebos
    /**
     * Initialize the schema (tables)
     */
    static function __initSchema()
    {
        if (empty(self::$__cacheSchemaChanges['vtiger_links'])) {
            if (!Vtiger_Utils::CheckTable('vtiger_links')) {
                Vtiger_Utils::CreateTable('vtiger_links', '(linkid INT NOT NULL PRIMARY KEY,
					tabid INT, linktype VARCHAR(20), linklabel VARCHAR(30), linkurl VARCHAR(255), linkicon VARCHAR(100), sequence INT, status INT(1) NOT NULL DEFAULT 1)', true);
                Vtiger_Utils::ExecuteQuery('CREATE INDEX link_tabidtype_idx on vtiger_links(tabid,linktype)');
            }
            self::$__cacheSchemaChanges['vtiger_links'] = true;
        }
    }
 public static function isLockedForModule($module)
 {
     $adb = PearDatabase::getInstance();
     if (Vtiger_Utils::CheckTable('vtiger_import_locks')) {
         $lockResult = $adb->pquery('SELECT * FROM vtiger_import_locks WHERE tabid=?', array(getTabid($module)));
         if ($lockResult && $adb->num_rows($lockResult) > 0) {
             $lockInfo = $adb->query_result_rowdata($lockResult, 0);
             return $lockInfo;
         }
     }
     return null;
 }
示例#7
0
 public static function getImportInfoById($importId)
 {
     $db = PearDatabase::getInstance();
     if (Vtiger_Utils::CheckTable('vtiger_import_queue')) {
         $queueResult = $db->pquery('SELECT * FROM vtiger_import_queue WHERE importid=?', array($importId));
         if ($queueResult && $db->num_rows($queueResult) > 0) {
             $rowData = $db->raw_query_result_rowdata($queueResult, 0);
             return self::getImportInfoFromResult($rowData);
         }
     }
     return null;
 }
示例#8
0
 /**
  * Set values for picklist field (non-role based)
  * @param Array List of values to add
  *
  * @internal Creates picklist base if it does not exists
  * @access private
  */
 function setNoRolePicklistValues($values)
 {
     global $adb;
     $picklist_table = 'vtiger_' . $this->name;
     $picklist_idcol = $this->name . 'id';
     if (!Vtiger_Utils::CheckTable($picklist_table)) {
         Vtiger_Utils::CreateTable($picklist_table, "({$picklist_idcol} INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t\t{$this->name} VARCHAR(200) NOT NULL,\n\t\t\t\tsortorderid INT(11),\n\t\t\t\tpresence INT (11) NOT NULL DEFAULT 1)", true);
         self::log("Creating table {$picklist_table} ... DONE");
     }
     // Add value to picklist now
     $sortid = 1;
     foreach ($values as $value) {
         $presence = 1;
         // 0 - readonly, Refer function in include/ComboUtil.php
         $new_id = $adb->getUniqueId($picklist_table);
         $adb->pquery("INSERT INTO {$picklist_table}({$picklist_idcol}, {$this->name}, sortorderid, presence) VALUES(?,?,?,?)", array($new_id, $value, $sortid, $presence));
         $sortid = $sortid + 1;
     }
 }
示例#9
0
 public static function initializeSchema()
 {
     if (!Vtiger_Utils::CheckTable('vtiger_google_oauth')) {
         Vtiger_Utils::CreateTable('vtiger_google_oauth', '(service varchar(64),request_token text,access_token text,userid int)', true);
     }
 }
示例#10
0
 /**
  * Initialize Language Schema
  * @access private
  */
 static function __initSchema()
 {
     $hastable = Vtiger_Utils::CheckTable(self::TABLENAME);
     if (!$hastable) {
         Vtiger_Utils::CreateTable(self::TABLENAME, '(id INT NOT NULL PRIMARY KEY,
                         name VARCHAR(50), label VARCHAR(30), lastupdated DATETIME, isdefault INT(1), active INT(1))', true);
         global $languages, $adb;
         foreach ($languages as $langkey => $langlabel) {
             $uniqueid = self::__getUniqueId();
             $adb->pquery('INSERT INTO ' . self::TABLENAME . '(id,name,label,lastupdated,isdefault,active) VALUES(?,?,?,?,?,?)', array($uniqueid, $langlabel, $langlabel, date('Y-m-d H:i:s', time()), 0, 1));
         }
     }
 }
示例#11
0
 protected function transferOwnership($transferToGroup)
 {
     $db = PearDatabase::getInstance();
     $groupId = $this->getId();
     $transferGroupId = $transferToGroup->getId();
     $query = 'UPDATE vtiger_crmentity SET smownerid=? WHERE smownerid=?';
     $params = array($transferGroupId, $groupId);
     $db->pquery($query, $params);
     if (Vtiger_Utils::CheckTable('vtiger_customerportal_prefs')) {
         $query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
         $params = array($transferGroupId, 'defaultassignee', $groupId);
         $db->pquery($query, $params);
         $query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
         $params = array($transferGroupId, 'userid', $groupId);
         $db->pquery($query, $params);
     }
     //update workflow tasks Assigned User from Deleted Group to Transfer Owner
     $newOwnerModel = $this->getInstance($transferGroupId);
     if (!$newOwnerModel) {
         $newOwnerModel = Users_Record_Model::getInstanceById($transferGroupId, 'Users');
     }
     $ownerModel = $this->getInstance($groupId);
     vtws_transferOwnershipForWorkflowTasks($ownerModel, $newOwnerModel);
     vtws_updateWebformsRoundrobinUsersLists($groupId, $transferGroupId);
 }
示例#12
0
	/**
	 * Active inventory blocks
	 * @param string $moduleName Module name
	 * @return string/false
	 */
	public function setInventoryTable($type)
	{
		$db = PearDatabase::getInstance();
		$moduleName = $this->name;

		$focus = CRMEntity::getInstance($moduleName);
		$basetable = $focus->table_name;
		$basetableid = $focus->table_index;

		$tableEnds = ['_inventory', '_invfield', '_invmap'];

		if ($type === true || $type === 'true') {
			$type = 1;
		} else {
			$type = 0;
		}
		$result = $db->updateBlob('vtiger_tab', 'type', [$type, $moduleName], 'name = ?');
		$i = 0;
		while ($result && $type && $ends = $tableEnds[$i]) {
			switch ($ends) {
				case '_inventory':
					$sql = '(id int(19),seq int(10),KEY id (id),CONSTRAINT `fk_1_' . $basetable . $ends . '` FOREIGN KEY (`id`) REFERENCES `' . $basetable . '` (`' . $basetableid . '`) ON DELETE CASCADE)';
					break;
				case '_invfield':
					$sql = "(id int(19) AUTO_INCREMENT PRIMARY KEY, columnname varchar(30) NOT NULL, label varchar(50) NOT NULL, invtype varchar(30) NOT NULL,presence tinyint(1) unsigned NOT NULL DEFAULT '0',
					defaultvalue varchar(255),sequence int(10) unsigned NOT NULL, block tinyint(1) unsigned NOT NULL,displaytype tinyint(1) unsigned NOT NULL DEFAULT '1', params text, colspan tinyint(1) unsigned NOT NULL DEFAULT '1')";
					break;
				case '_invmap':
					$sql = '(module varchar(50) PRIMARY KEY,field varchar(50),tofield varchar(50))';
					break;
			}
			if (!Vtiger_Utils::CheckTable($basetable . $ends)) {
				Vtiger_Utils::CreateTable($basetable . $ends, $sql, true);
			}
			$i++;
		}
		return $result;
	}
 /**
  * Get all the language information
  * @param Boolean true to include in-active languages also, false (default)
  */
 static function getAll($includeInActive = false)
 {
     global $adb;
     $hastable = Vtiger_Utils::CheckTable(self::TABLENAME);
     $languageinfo = array();
     if ($hastable) {
         if ($includeInActive) {
             $result = $adb->pquery('SELECT * FROM ' . self::TABLENAME, array());
         } else {
             $result = $adb->pquery('SELECT * FROM ' . self::TABLENAME . ' WHERE active=?', array(1));
         }
         for ($index = 0; $index < $adb->num_rows($result); ++$index) {
             $resultrow = $adb->fetch_array($result);
             $prefix = $resultrow['prefix'];
             $label = $resultrow['label'];
             $languageinfo[$prefix] = $label;
         }
     } else {
         global $languages;
         foreach ($languages as $prefix => $label) {
             $languageinfo[$prefix] = $label;
         }
     }
     // SalesPlatform.ru begin Set ru_ru to first position
     if ($languageinfo['ru_ru']) {
         $ruLabel = $languageinfo['ru_ru'];
         unset($languageinfo['ru_ru']);
         $languageinfo = array_merge(array('ru_ru' => $ruLabel), $languageinfo);
     }
     // SalesPlatform.ru end
     return $languageinfo;
 }
示例#14
0
 /**
  * Initialize Layout Schema
  * @access private
  */
 static function __initSchema()
 {
     $hastable = Vtiger_Utils::CheckTable(self::TABLENAME);
     if (!$hastable) {
         Vtiger_Utils::CreateTable(self::TABLENAME, '(id INT NOT NULL PRIMARY KEY,
                         name VARCHAR(50), label VARCHAR(30), lastupdated DATETIME, isdefault INT(1), active INT(1))', true);
     }
 }
示例#15
0
/** Function to transfer the ownership of records owned by a particular group to the specified group
 * @param $groupId -- Group Id of the group which's record ownership has to be transferred:: Type integer
 * @param $transferId --  Id of the group/user to which record ownership is to be transferred:: Type integer
 * @param $transferType -- It can have only two values namely 'Groups' or 'Users'. This determines whether the owneship is to be transferred to a group or user :: Type varchar
 */
function tranferGroupOwnership($groupId, $transferId)
{
    global $log;
    $log->debug("Entering tranferGroupOwnership(" . $groupId . ") method ...");
    global $adb;
    $query = "update vtiger_crmentity set smownerid=? where smownerid=?";
    $params = array($transferId, $groupId);
    $adb->pquery($query, $params);
    if (Vtiger_Utils::CheckTable('vtiger_customerportal_prefs')) {
        $query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
        $params = array($transferId, 'defaultassignee', $groupId);
        $adb->pquery($query, $params);
        $query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
        $params = array($transferId, 'userid', $groupId);
        $adb->pquery($query, $params);
    }
    $log->debug("Exiting tranferGroupOwnership method ...");
}
示例#16
0
function vtws_transferOwnership($ownerId, $newOwnerId, $delete = true)
{
    $db = PearDatabase::getInstance();
    //Updating the smcreatorid,smownerid, modifiedby in vtiger_crmentity
    $sql = "UPDATE vtiger_crmentity SET smcreatorid=? WHERE smcreatorid=? AND setype<>?";
    $db->pquery($sql, array($newOwnerId, $ownerId, 'ModComments'));
    $sql = "UPDATE vtiger_crmentity SET smownerid=? WHERE smownerid=? AND setype<>?";
    $db->pquery($sql, array($newOwnerId, $ownerId, 'ModComments'));
    $sql = "update vtiger_crmentity set modifiedby=? where modifiedby=?";
    $db->pquery($sql, array($newOwnerId, $ownerId));
    //deleting from vtiger_tracker
    if ($delete) {
        $sql = "delete from vtiger_tracker where user_id=?";
        $db->pquery($sql, array($ownerId));
    }
    //updating the vtiger_import_maps
    $sql = "update vtiger_import_maps set assigned_user_id=? where assigned_user_id=?";
    $db->pquery($sql, array($newOwnerId, $ownerId));
    if (Vtiger_Utils::CheckTable('vtiger_customerportal_prefs')) {
        $query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
        $params = array($newOwnerId, 'defaultassignee', $ownerId);
        $db->pquery($query, $params);
        $query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
        $params = array($newOwnerId, 'userid', $ownerId);
        $db->pquery($query, $params);
    }
    //delete from vtiger_homestuff
    if ($delete) {
        $sql = "delete from vtiger_homestuff where userid=?";
        $db->pquery($sql, array($ownerId));
    }
    //delete from vtiger_users to vtiger_role vtiger_table
    if ($delete) {
        $sql = "delete from vtiger_users2group where userid=?";
        $db->pquery($sql, array($ownerId));
    }
    $sql = "select tabid,fieldname,tablename,columnname from vtiger_field left join " . "vtiger_fieldmodulerel on vtiger_field.fieldid=vtiger_fieldmodulerel.fieldid where uitype " . "in (52,53,77,101) or (uitype=10 and relmodule='Users')";
    $result = $db->pquery($sql, array());
    $it = new SqlResultIterator($db, $result);
    $columnList = array();
    foreach ($it as $row) {
        $column = $row->tablename . '.' . $row->columnname;
        if (!in_array($column, $columnList)) {
            $columnList[] = $column;
            if ($row->columnname == 'smcreatorid' || $row->columnname == 'smownerid') {
                $sql = "update {$row->tablename} set {$row->columnname}=? where {$row->columnname}=? and setype<>?";
                $db->pquery($sql, array($newOwnerId, $ownerId, 'ModComments'));
            } else {
                $sql = "update {$row->tablename} set {$row->columnname}=? where {$row->columnname}=?";
                $db->pquery($sql, array($newOwnerId, $ownerId));
            }
        }
    }
    //update workflow tasks Assigned User from Deleted User to Transfer User
    $newOwnerModel = Users_Record_Model::getInstanceById($newOwnerId, 'Users');
    $ownerModel = Users_Record_Model::getInstanceById($ownerId, 'Users');
    vtws_transferOwnershipForWorkflowTasks($ownerModel, $newOwnerModel);
    vtws_updateWebformsRoundrobinUsersLists($ownerId, $newOwnerId);
}
示例#17
0
 /**
  * Create this module instance
  * @access private
  */
 function __create()
 {
     $adb = PearDatabase::getInstance();
     self::log("Creating Module {$this->name} ... STARTED");
     $this->id = $this->__getUniqueId();
     if (!$this->tabsequence) {
         $this->tabsequence = $this->__getNextSequence();
     }
     if (!$this->label) {
         $this->label = $this->name;
     }
     $customized = 1;
     // To indicate this is a Custom Module
     $this->__handleVtigerCoreSchemaChanges();
     $adb->insert('vtiger_tab', ['tabid' => $this->id, 'name' => $this->name, 'presence' => $this->presence, 'tabsequence' => -1, 'tablabel' => $this->label, 'modifiedby' => NULL, 'modifiedtime' => NULL, 'customized' => $customized, 'ownedby' => $this->ownedby, 'version' => $this->version, 'parent' => $this->parent, 'isentitytype' => $this->isentitytype ? 1 : 0, 'type' => $this->type]);
     if (!Vtiger_Utils::CheckTable('vtiger_tab_info')) {
         Vtiger_Utils::CreateTable('vtiger_tab_info', '(tabid INT, prefname VARCHAR(256), prefvalue VARCHAR(256), FOREIGN KEY fk_1_vtiger_tab_info(tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE ON UPDATE CASCADE)', true);
     }
     if ($this->minversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_min_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_min_version'", array($this->minversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_min_version', $this->minversion));
         }
     }
     if ($this->maxversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_max_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_max_version'", array($this->maxversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_max_version', $this->maxversion));
         }
     }
     Vtiger_Profile::initForModule($this);
     self::syncfile();
     if ($this->isentitytype) {
         Vtiger_Access::initSharing($this);
     }
     $moduleInstance = Vtiger_Module::getInstance($this->name);
     $parentTab = $this->parent;
     if (!empty($parentTab)) {
     }
     self::log("Creating Module {$this->name} ... DONE");
 }
示例#18
0
 /**
  *  Creates sync table if not exists
  */
 private static function intialiseUpdateSchema()
 {
     if (!Vtiger_Utils::CheckTable('vtiger_google_sync')) {
         Vtiger_Utils::CreateTable('vtiger_google_sync', '(googlemodule varchar(50),user int(10), synctime datetime,lastsynctime datetime)', true);
     }
 }
示例#19
0
 /**
  * Get all the language information
  * @param Boolean true to include in-active languages also, false (default)
  */
 static function getAll($includeInActive = false)
 {
     global $adb;
     $hastable = Vtiger_Utils::CheckTable(self::TABLENAME);
     $languageinfo = array();
     if ($hastable) {
         if ($includeInActive) {
             $result = $adb->pquery('SELECT * FROM ' . self::TABLENAME, array());
         } else {
             $result = $adb->pquery('SELECT * FROM ' . self::TABLENAME . ' WHERE active=?', array(1));
         }
         for ($index = 0; $index < $adb->num_rows($result); ++$index) {
             $resultrow = $adb->fetch_array($result);
             $prefix = $resultrow['prefix'];
             $label = $resultrow['label'];
             $languageinfo[$prefix] = $label;
         }
     } else {
         global $languages;
         foreach ($languages as $prefix => $label) {
             $languageinfo[$prefix] = $label;
         }
     }
     return $languageinfo;
 }
示例#20
0
                for ($j = 0; $j < $noOfConditions; $j++) {
                    $columnIndex = $adb->query_result($relcriteriaResult, $j, 'columnindex');
                    if ($maxColumnIndex < $columnIndex) {
                        $maxColumnIndex = $columnIndex;
                    }
                    $columnIndexArray[] = $columnIndex;
                }
                $conditionExpression = implode(' and ', $columnIndexArray);
                $adb->pquery('INSERT INTO vtiger_relcriteria_grouping VALUES(?,?,?,?)', array(1, $reportId, '', $conditionExpression));
                $adb->pquery("UPDATE vtiger_relcriteria SET column_condition='' WHERE columnindex=? AND queryid=?", array($maxColumnIndex, $reportId));
            }
        }
    }
}
ExecuteQuery("CREATE TABLE IF NOT EXISTS `vtiger_customerportal_tabs` ( `tabid` int(19) NOT NULL, `visible` int(1)\n\tdefault '1', `sequence` int(1) default NULL, PRIMARY KEY  (`tabid`)) ENGINE=InnoDB\n\tDEFAULT CHARSET=utf8");
if (Vtiger_Utils::CheckTable('vtiger_customerportal_prefs')) {
    ExecuteQuery("ALTER TABLE `vtiger_customerportal_prefs` DROP INDEX tabid_idx");
    ExecuteQuery("ALTER TABLE `vtiger_customerportal_prefs` ADD PRIMARY KEY  (`tabid`)");
} else {
    ExecuteQuery("CREATE TABLE IF NOT EXISTS `vtiger_customerportal_prefs` ( `tabid` int(11) NOT NULL, `prefkey`\n\t\tvarchar(100) default NULL, `prefvalue` int(20) default NULL, PRIMARY KEY  (`tabid`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8");
}
//Adding Block to email fields
$blockquery = "select blockid from vtiger_blocks where blocklabel = ?";
$blockres = $adb->pquery($blockquery, array('LBL_EMAIL_INFORMATION'));
$blockid = $adb->query_result($blockres, 0, 'blockid');
$fieldsqueryuitype8 = 'update vtiger_field set block=? where tabid=? and uitype=8';
$adb->pquery($fieldsqueryuitype8, array($blockid, $email_Tabid));
$fieldsqueryuitype12 = 'update vtiger_field set block=? where tabid=? and uitype=12';
$adb->pquery($fieldsqueryuitype12, array($blockid, $email_Tabid));
$fieldsqueryuitype1 = 'update vtiger_field set block=? where tabid=? and uitype=1';
$adb->pquery($fieldsqueryuitype1, array($blockid, $email_Tabid));
 /**
  * Dispatch (send) email that was queued.
  */
 static function dispatchQueue(Vtiger_Mailer_Listener $listener = null)
 {
     global $adb;
     if (!Vtiger_Utils::CheckTable('vtiger_mailer_queue')) {
         return;
     }
     $mailer = new self();
     $queue = $adb->pquery('SELECT * FROM vtiger_mailer_queue WHERE failed != ?', array(1));
     if ($adb->num_rows($queue)) {
         for ($index = 0; $index < $adb->num_rows($queue); ++$index) {
             $mailer->reinitialize();
             $queue_record = $adb->fetch_array($queue, $index);
             $queueid = $queue_record['id'];
             $relcrmid = $queue_record['relcrmid'];
             $mailer->From = $queue_record['fromemail'];
             $mailer->From = $queue_record['fromname'];
             $mailer->Subject = $queue_record['subject'];
             $mailer->Body = decode_html($queue_record['body']);
             $mailer->Mailer = $queue_record['mailer'];
             $mailer->ContentType = $queue_record['content_type'];
             $emails = $adb->pquery('SELECT * FROM vtiger_mailer_queueinfo WHERE id=?', array($queueid));
             for ($eidx = 0; $eidx < $adb->num_rows($emails); ++$eidx) {
                 $email_record = $adb->fetch_array($emails, $eidx);
                 if ($email_record[type] == 'TO') {
                     $mailer->AddAddress($email_record[email], $email_record[name]);
                 } else {
                     if ($email_record[type] == 'CC') {
                         $mailer->AddCC($email_record[email], $email_record[name]);
                     } else {
                         if ($email_record[type] == 'BCC') {
                             $mailer->AddBCC($email_record[email], $email_record[name]);
                         } else {
                             if ($email_record[type] == 'RPLYTO') {
                                 $mailer->AddReplyTo($email_record[email], $email_record[name]);
                             }
                         }
                     }
                 }
             }
             $attachments = $adb->pquery('SELECT * FROM vtiger_mailer_queueattachments WHERE id=?', array($queueid));
             for ($aidx = 0; $aidx < $adb->num_rows($attachments); ++$aidx) {
                 $attachment_record = $adb->fetch_array($attachments, $aidx);
                 if ($attachment_record['path'] != '') {
                     $mailer->AddAttachment($attachment_record['path'], $attachment_record['name'], $attachment_record['encoding'], $attachment_record['type']);
                 }
             }
             $sent = $mailer->Send(true);
             if ($sent) {
                 Vtiger_Event::trigger('vtiger.mailer.mailsent', $relcrmid);
                 if ($listener) {
                     $listener->mailsent($queueid);
                 }
                 $adb->pquery('DELETE FROM vtiger_mailer_queue WHERE id=?', array($queueid));
                 $adb->pquery('DELETE FROM vtiger_mailer_queueinfo WHERE id=?', array($queueid));
                 $adb->pquery('DELETE FROM vtiger_mailer_queueattachments WHERE id=?', array($queueid));
             } else {
                 if ($listener) {
                     $listener->mailerror($queueid);
                 }
                 $adb->pquery('UPDATE vtiger_mailer_queue SET failed=?, failreason=? WHERE id=?', array(1, $mailer->ErrorInfo, $queueid));
             }
         }
     }
 }
示例#22
0
 public function getPicklistId($fieldName, $value)
 {
     global $log, $adb;
     $log->debug("Entering YetiForceUpdate::getPicklistId(" . $fieldName . ',' . $value . ") method ...");
     if (Vtiger_Utils::CheckTable('vtiger_' . $fieldName)) {
         $sql = 'SELECT * FROM vtiger_' . $fieldName . ' WHERE ' . $fieldName . ' = ? ;';
         $result = $adb->pquery($sql, array($value));
         if ($adb->num_rows($result) > 0) {
             $log->debug("Exiting YetiForceUpdate::getPicklistId() method ...");
             return $adb->query_result($result, 0, 'picklist_valueid');
         }
     }
     $log->debug("Exiting YetiForceUpdate::getPicklistId() method ...");
     return false;
 }
示例#23
0
 public static function isUserImportBlocked($user)
 {
     $adb = PearDatabase::getInstance();
     $tableName = self::getDbTableName($user);
     if (Vtiger_Utils::CheckTable($tableName)) {
         $result = $adb->query('SELECT 1 FROM ' . $tableName . ' WHERE temp_status = ' . Import_Data_Action::$IMPORT_RECORD_NONE);
         if ($adb->num_rows($result) > 0) {
             return true;
         }
     }
     return false;
 }
示例#24
0
 /**
  *
  * @param String $packagepath - path to the package file.
  * @return Array
  */
 static function getOptionalModuleDetails($package, $optionalModulesInfo)
 {
     global $optionalModuleStrings;
     $moduleUpdateVersion = $package->getVersion();
     $moduleForVtigerVersion = $package->getDependentVtigerVersion();
     $moduleMaxVtigerVersion = $package->getDependentMaxVtigerVersion();
     if ($package->isLanguageType()) {
         $type = 'language';
     } else {
         $type = 'module';
     }
     $moduleDetails = null;
     $moduleName = $package->getModuleName();
     if ($moduleName != null) {
         $moduleDetails = array();
         $moduleDetails['description'] = $optionalModuleStrings[$moduleName . '_description'];
         if (Vtiger_Version::check($moduleForVtigerVersion, '>=') && Vtiger_Version::check($moduleMaxVtigerVersion, '<')) {
             $moduleDetails['selected'] = true;
             $moduleDetails['enabled'] = true;
         } else {
             $moduleDetails['selected'] = false;
             $moduleDetails['enabled'] = false;
         }
         $migrationAction = 'install';
         if (!$package->isLanguageType()) {
             $moduleInstance = null;
             if (Vtiger_Utils::checkTable('vtiger_tab')) {
                 $moduleInstance = Vtiger_Module::getInstance($moduleName);
             }
             if ($moduleInstance) {
                 $migrationAction = 'update';
                 if (version_compare($moduleUpdateVersion, $moduleInstance->version, '>=')) {
                     $moduleDetails['enabled'] = false;
                 }
             }
         } else {
             if (Vtiger_Utils::CheckTable(Vtiger_Language::TABLENAME)) {
                 $languageList = array_keys(Vtiger_Language::getAll());
                 $prefix = $package->getPrefix();
                 if (in_array($prefix, $languageList)) {
                     $migrationAction = 'update';
                 }
             }
         }
         $optionalModulesInfo[$migrationAction][$type][$moduleName] = $moduleDetails;
     }
     return $optionalModulesInfo;
 }
示例#25
0
文件: Utils.php 项目: kduqi/corebos
function vtws_transferOwnership($ownerId, $newOwnerId, $delete = true)
{
    $db = PearDatabase::getInstance();
    //Updating the smcreatorid,smownerid, modifiedby in vtiger_crmentity
    $sql = "update vtiger_crmentity set smcreatorid=? where smcreatorid=?";
    $db->pquery($sql, array($newOwnerId, $ownerId));
    $sql = "update vtiger_crmentity set smownerid=? where smownerid=?";
    $db->pquery($sql, array($newOwnerId, $ownerId));
    $sql = "update vtiger_crmentity set modifiedby=? where modifiedby=?";
    $db->pquery($sql, array($newOwnerId, $ownerId));
    //deleting from vtiger_tracker
    if ($delete) {
        $sql = "delete from vtiger_tracker where user_id=?";
        $db->pquery($sql, array($ownerId));
    }
    //updating the vtiger_import_maps
    $sql = "update vtiger_import_maps set assigned_user_id=? where assigned_user_id=?";
    $db->pquery($sql, array($newOwnerId, $ownerId));
    if (Vtiger_Utils::CheckTable('vtiger_customerportal_prefs')) {
        $query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
        $params = array($newOwnerId, 'defaultassignee', $ownerId);
        $db->pquery($query, $params);
        $query = 'UPDATE vtiger_customerportal_prefs SET prefvalue = ? WHERE prefkey = ? AND prefvalue = ?';
        $params = array($newOwnerId, 'userid', $ownerId);
        $db->pquery($query, $params);
    }
    //delete from vtiger_homestuff
    if ($delete) {
        $sql = "delete from vtiger_homestuff where userid=?";
        $db->pquery($sql, array($ownerId));
    }
    //delete from vtiger_users to group vtiger_table
    if ($delete) {
        $sql = "delete from vtiger_user2role where userid=?";
        $db->pquery($sql, array($ownerId));
    }
    //delete from vtiger_users to vtiger_role vtiger_table
    if ($delete) {
        $sql = "delete from vtiger_users2group where userid=?";
        $db->pquery($sql, array($ownerId));
    }
    $sql = "select tabid,fieldname,tablename,columnname from vtiger_field left join " . "vtiger_fieldmodulerel on vtiger_field.fieldid=vtiger_fieldmodulerel.fieldid where uitype " . "in (52,53,77,101) or (uitype=10 and relmodule='Users')";
    $result = $db->pquery($sql, array());
    $it = new SqlResultIterator($db, $result);
    $columnList = array();
    foreach ($it as $row) {
        $column = $row->tablename . '.' . $row->columnname;
        if (!in_array($column, $columnList)) {
            $columnList[] = $column;
            $sql = "update {$row->tablename} set {$row->columnname}=? where {$row->columnname}=?";
            $db->pquery($sql, array($newOwnerId, $ownerId));
        }
    }
}
示例#26
0
    /**
     * Initialize the schema.
     */
    protected static function initializeSchema()
    {
        if (!self::$schemaInitialized) {
            if (!Vtiger_Utils::CheckTable('vtiger_cron_task')) {
                Vtiger_Utils::CreateTable('vtiger_cron_task', '(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
					name VARCHAR(100) UNIQUE KEY, handler_file VARCHAR(100) UNIQUE KEY,
					frequency int, laststart int(11) unsigned, lastend int(11) unsigned, status int,module VARCHAR(100),
                                        sequence int,description TEXT )', true);
            }
            self::$schemaInitialized = true;
        }
    }
示例#27
0
 /**
  * Create this module instance
  * @access private
  */
 function __create()
 {
     global $adb;
     self::log("Creating Module {$this->name} ... STARTED");
     $this->id = $this->__getUniqueId();
     if (!$this->tabsequence) {
         $this->tabsequence = $this->__getNextSequence();
     }
     if (!$this->label) {
         $this->label = $this->name;
     }
     $customized = 1;
     // To indicate this is a Custom Module
     $this->__handleVtigerCoreSchemaChanges();
     $adb->pquery("INSERT INTO vtiger_tab (tabid,name,presence,tabsequence,tablabel,modifiedby,\n\t\t\tmodifiedtime,customized,ownedby,version,parent) VALUES (?,?,?,?,?,?,?,?,?,?,?)", array($this->id, $this->name, $this->presence, -1, $this->label, NULL, NULL, $customized, $this->ownedby, $this->version, $this->parent));
     $useisentitytype = $this->isentitytype ? 1 : 0;
     $adb->pquery('UPDATE vtiger_tab set isentitytype=? WHERE tabid=?', array($useisentitytype, $this->id));
     if (!Vtiger_Utils::CheckTable('vtiger_tab_info')) {
         Vtiger_Utils::CreateTable('vtiger_tab_info', '(tabid INT, prefname VARCHAR(256), prefvalue VARCHAR(256), FOREIGN KEY fk_1_vtiger_tab_info(tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE ON UPDATE CASCADE)', true);
     }
     if ($this->minversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_min_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_min_version'", array($this->minversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_min_version', $this->minversion));
         }
     }
     if ($this->maxversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_max_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_max_version'", array($this->maxversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_max_version', $this->maxversion));
         }
     }
     Vtiger_Profile::initForModule($this);
     self::syncfile();
     if ($this->isentitytype) {
         Vtiger_Access::initSharing($this);
     }
     $moduleInstance = Vtiger_Module::getInstance($this->name);
     $parentTab = $this->parent;
     if (!empty($parentTab)) {
         $menuInstance = Vtiger_Menu::getInstance($parentTab);
         $menuInstance->addModule($moduleInstance);
     }
     self::log("Creating Module {$this->name} ... DONE");
 }
示例#28
0
 /**
  * Set relation between field and modules (UIType 10)
  * @param Array List of module names
  *
  * @internal Creates table vtiger_fieldmodulerel if it does not exists
  */
 function setRelatedModules($moduleNames)
 {
     // We need to create core table to capture the relation between the field and modules.
     if (!Vtiger_Utils::CheckTable('vtiger_fieldmodulerel')) {
         Vtiger_Utils::CreateTable('vtiger_fieldmodulerel', '(fieldid INT NOT NULL, module VARCHAR(100) NOT NULL, relmodule VARCHAR(100) NOT NULL, status VARCHAR(10), sequence INT)', true);
     }
     // END
     global $adb;
     foreach ($moduleNames as $relmodule) {
         $checkres = $adb->pquery('SELECT * FROM vtiger_fieldmodulerel WHERE fieldid=? AND module=? AND relmodule=?', array($this->id, $this->getModuleName(), $relmodule));
         // If relation already exist continue
         if ($adb->num_rows($checkres)) {
             continue;
         }
         $adb->pquery('INSERT INTO vtiger_fieldmodulerel(fieldid, module, relmodule) VALUES(?,?,?)', array($this->id, $this->getModuleName(), $relmodule));
         self::log("Setting {$this->name} relation with {$relmodule} ... DONE");
     }
     return true;
 }
示例#29
0
    $res = Migration_Index_View::ExecuteQuery($sql, array('Google_vtigerSyncHandler', $appKey));
}
//Ends 141
//Google Calendar sync changes
/**
 * Please refer this trac (http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/8354#comment:3)
 * for configuration of vtiger to Google OAuth2
 */
global $adb;
if (!Vtiger_Utils::CheckTable('vtiger_google_oauth2')) {
    Vtiger_Utils::CreateTable('vtiger_google_oauth2', '(service varchar(20),access_token varchar(500),refresh_token varchar(500),userid int(19))', true);
    echo '<br> vtiger_google_oauth2 table created <br>';
}
//(start)Migrating GoogleCalendar ClientIds in wsapp_recordmapping to support v3
$syncTrackerIds = array();
if (Vtiger_Utils::CheckTable('vtiger_wsapp_sync_state')) {
    $sql = 'SELECT stateencodedvalues from vtiger_wsapp_sync_state WHERE name = ?';
    $result = $db->pquery($sql, array('Vtiger_GoogleCalendar'));
    $num_of_rows = $adb->num_rows($result);
    for ($i = 0; $i < $num_of_rows; $i++) {
        $stateEncodedValues = $adb->query_result($result, $i, 'stateencodedvalues');
        $htmlDecodedStateEncodedValue = decode_html($stateEncodedValues);
        $stateDecodedValues = json_decode($htmlDecodedStateEncodedValue, true);
        if (is_array($stateDecodedValues) && isset($stateDecodedValues['synctrackerid'])) {
            $syncTrackerIds[] = $stateDecodedValues['synctrackerid'];
        }
    }
}
//$syncTrackerIds - list of all Calendar sync trackerIds
$appIds = array();
if (count($syncTrackerIds)) {
    $moduleInstance->addLink('LISTVIEWSIDEBARWIDGET', 'Google Contacts', 'module=Google&view=List&sourcemodule=Contacts', '', '', '');
}
$moduleInstance = Vtiger_Module::getInstance('Calendar');
if ($moduleInstance) {
    $moduleInstance->addLink('LISTVIEWSIDEBARWIDGET', 'Google Calendar', 'module=Google&view=List&sourcemodule=Calendar', '', '', '');
}
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_cvadvfilter MODIFY comparator VARCHAR(20)', array());
Migration_Index_View::ExecuteQuery('UPDATE vtiger_cvadvfilter SET comparator = ? WHERE comparator = ?', array('next120days', 'next120day'));
Migration_Index_View::ExecuteQuery('UPDATE vtiger_cvadvfilter SET comparator = ? WHERE comparator = ?', array('last120days', 'last120day'));
Migration_Index_View::ExecuteQuery("UPDATE vtiger_relatedlists SET actions = ? WHERE tabid = ? AND related_tabid IN (?, ?)", array('ADD', getTabid('Project'), getTabid('ProjectTask'), getTabid('ProjectMilestone')));
Migration_Index_View::ExecuteQuery("UPDATE vtiger_field SET typeofdata = ? WHERE columnname = ? AND tablename = ?", array("V~O", "company", "vtiger_leaddetails"));
if (Vtiger_Utils::CheckTable('vtiger_cron_task')) {
    Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_cron_task MODIFY COLUMN laststart INT(11) UNSIGNED', array());
    Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_cron_task MODIFY COLUMN lastend INT(11) UNSIGNED', array());
}
if (Vtiger_Utils::CheckTable('vtiger_cron_log')) {
    Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_cron_log MODIFY COLUMN start INT(11) UNSIGNED', array());
    Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_cron_log MODIFY COLUMN end INT(11) UNSIGNED', array());
}
require_once 'vtlib/Vtiger/Cron.php';
Vtiger_Cron::deregister('ScheduleReports');
// END 2013.02.18
// Start 2013.03.19
// Mail Converter schema changes
Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_mailscanner ADD COLUMN timezone VARCHAR(10) default NULL', array());
Migration_Index_View::ExecuteQuery('UPDATE vtiger_mailscanner SET timezone=? WHERE server LIKE ? AND timezone IS NULL', array('-8:00', '%.gmail.com'));
Migration_Index_View::ExecuteQuery('UPDATE vtiger_report SET state=?', array('CUSTOM'));
Migration_Index_View::ExecuteQuery("ALTER TABLE vtiger_relcriteria MODIFY value VARCHAR(512)", array());
Migration_Index_View::ExecuteQuery("ALTER TABLE vtiger_cvadvfilter MODIFY value VARCHAR(512)", array());
// End 2013.03.19
// Start 2013.04.23