Commit af321125 authored by totten's avatar totten
Browse files

Merge pull request #4863 from totten/master-phpcbf4

INFRA-132 - Mass PHP cleanup
parents a716bec6 5896d037

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -49,8 +49,10 @@ class CRM_ACL_API {
/**
* Given a permission string, check for access requirements
*
* @param string $str the permission to check
* @param int $contactID the contactID for whom the check is made
* @param string $str
* The permission to check.
* @param int $contactID
* The contactID for whom the check is made.
*
* @return boolean true if yes, else false
* @static
......@@ -72,21 +74,28 @@ class CRM_ACL_API {
/**
* Get the permissioned where clause for the user
*
* @param int $type the type of permission needed
* @param array $tables (reference ) add the tables that are needed for the select clause
* @param array $whereTables (reference ) add the tables that are needed for the where clause
* @param int $contactID the contactID for whom the check is made
* @param bool $onlyDeleted whether to include only deleted contacts
* @param bool $skipDeleteClause don't add delete clause if this is true,
* @param int $type
* The type of permission needed.
* @param array $tables
* (reference ) add the tables that are needed for the select clause.
* @param array $whereTables
* (reference ) add the tables that are needed for the where clause.
* @param int $contactID
* The contactID for whom the check is made.
* @param bool $onlyDeleted
* Whether to include only deleted contacts.
* @param bool $skipDeleteClause
* Don't add delete clause if this is true,.
* this means it is handled by generating query
*
* @return string the group where clause for this user
*/
public static function whereClause($type,
public static function whereClause(
$type,
&$tables,
&$whereTables,
$contactID = NULL,
$onlyDeleted = FALSE,
$contactID = NULL,
$onlyDeleted = FALSE,
$skipDeleteClause = FALSE
) {
// the default value which is valid for rhe final AND
......@@ -135,8 +144,10 @@ class CRM_ACL_API {
/**
* Get all the groups the user has access to for the given operation
*
* @param int $type the type of permission needed
* @param int $contactID the contactID for whom the check is made
* @param int $type
* The type of permission needed.
* @param int $contactID
* The contactID for whom the check is made.
*
* @param string $tableName
* @param null $allGroups
......@@ -146,9 +157,9 @@ class CRM_ACL_API {
*/
public static function group(
$type,
$contactID = NULL,
$tableName = 'civicrm_saved_search',
$allGroups = NULL,
$contactID = NULL,
$tableName = 'civicrm_saved_search',
$allGroups = NULL,
$includedGroups = NULL
) {
if ($contactID == NULL) {
......@@ -167,9 +178,11 @@ class CRM_ACL_API {
/**
* Check if the user has access to this group for operation $type
*
* @param int $type the type of permission needed
* @param int $type
* The type of permission needed.
* @param int $groupID
* @param int $contactID the contactID for whom the check is made
* @param int $contactID
* The contactID for whom the check is made.
*
* @param string $tableName
* @param null $allGroups
......@@ -181,9 +194,9 @@ class CRM_ACL_API {
public static function groupPermission(
$type,
$groupID,
$contactID = NULL,
$tableName = 'civicrm_saved_search',
$allGroups = NULL,
$contactID = NULL,
$tableName = 'civicrm_saved_search',
$allGroups = NULL,
$includedGroups = NULL,
$flush = FALSE
) {
......
......@@ -92,17 +92,24 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/**
* Construct a WHERE clause to handle permissions to $object_*
*
* @param array $tables - Any tables that may be needed in the FROM
* @param string $operation - The operation being attempted
* @param string $object_table - The table of the object in question
* @param int $object_id - The ID of the object in question
* @param int $acl_id - If it's a grant/revoke operation, the ACL ID
* @param boolean $acl_role - For grant operations, this flag determines if we're granting a single acl (false) or an entire group.
* @param array $tables
* Any tables that may be needed in the FROM.
* @param string $operation
* The operation being attempted.
* @param string $object_table
* The table of the object in question.
* @param int $object_id
* The ID of the object in question.
* @param int $acl_id
* If it's a grant/revoke operation, the ACL ID.
* @param bool $acl_role
* For grant operations, this flag determines if we're granting a single acl (false) or an entire group.
*
* @return string - The WHERE clause, or 0 on failure
* @static
*/
public static function permissionClause(&$tables, $operation,
public static function permissionClause(
&$tables, $operation,
$object_table = NULL, $object_id = NULL,
$acl_id = NULL, $acl_role = FALSE
) {
......@@ -124,7 +131,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/* Include clause if we're looking for a specific table/id permission */
if (!empty($object_table)) {
$where .= " AND ( {$t['ACL']}.object_table IS null
OR ({$t['ACL']}.object_table = '" . CRM_Utils_Type::escape($object_table, 'String') . "'";
......@@ -137,7 +143,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/* Include clause if we're granting an ACL or ACL Role */
if (!empty($acl_id)) {
$where .= " AND ({$t['ACL']}.acl_id IS null
OR {$t['ACL']}.acl_id = " . CRM_Utils_Type::escape($acl_id, 'Integer') . ')';
......@@ -153,7 +158,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/* Query for permissions granted to all contacts in the domain */
$query[] = "SELECT {$t['ACL']}.*, 0 as override
FROM {$t['ACL']}
......@@ -162,7 +166,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/* Query for permissions granted to all contacts through an ACL group */
$query[] = "SELECT {$t['ACL']}.*, 0 as override
FROM {$t['ACL']}
......@@ -182,7 +185,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/* Query for permissions granted directly to the contact */
$query[] = "SELECT {$t['ACL']}.*, 1 as override
FROM {$t['ACL']}
......@@ -195,7 +197,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/* Query for permissions granted to the contact through an ACL group */
$query[] = "SELECT {$t['ACL']}.*, 1 as override
FROM {$t['ACL']}
......@@ -215,7 +216,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/* Query for permissions granted to the contact through a group */
$query[] = "SELECT {$t['ACL']}.*, 0 as override
FROM {$t['ACL']}
......@@ -228,11 +228,9 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
AND {$t['GroupContact']}.contact_id = $contact_id
AND {$t['GroupContact']}.status = 'Added')";
/* Query for permissions granted through an ACL group to a Contact
* group */
$query[] = "SELECT {$t['ACL']}.*, 0 as override
FROM {$t['ACL']}
......@@ -270,7 +268,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
* 3) the rule governs the specific object we want
*/
if (empty($dao->object_table) ||
($dao->object_table == $object_table
&& (empty($dao->object_id)
......@@ -283,7 +280,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
else {
/* Otherwise try to generate a clause for this rule */
$clause = self::getClause(
$dao->object_table, $dao->object_id, $tables
);
......@@ -292,7 +288,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
* (id is null) on a table other than the one we're interested
* in. So skip it. */
if (empty($clause)) {
continue;
}
......@@ -301,7 +296,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/* Now we figure out if this is an allow or deny rule, and possibly
* a contact-level override */
if ($dao->deny) {
$deny[] = $clause;
}
......@@ -326,9 +320,12 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/**
* Given a table and id pair, return the filter clause
*
* @param string $table - The table owning the object
* @param int $id - The ID of the object
* @param array $tables - Tables that will be needed in the FROM
* @param string $table
* The table owning the object.
* @param int $id
* The ID of the object.
* @param array $tables
* Tables that will be needed in the FROM.
*
* @return string|null - WHERE-style clause to filter results,
* or null if $table or $id is null
......@@ -357,12 +354,14 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/**
* Construct an associative array of an ACL rule's properties
*
* @param string $format sprintf format for array
* @param bool $hideEmpty only return elements that have a value set.
* @param string $format
* Sprintf format for array.
* @param bool $hideEmpty
* Only return elements that have a value set.
*
* @return array - Assoc. array of the ACL rule's properties
*/
public function toArray($format = '%s', $hideEmpty = false) {
public function toArray($format = '%s', $hideEmpty = FALSE) {
$result = array();
if (!self::$_fieldKeys) {
......@@ -382,9 +381,12 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
* directly to the contact, but not those granted to the contact through
* any/all of his group memberships.
*
* @param int $contact_id - ID of a contact to search for
* @param int $group_id - ID of a group to search for
* @param boolean $aclRoles - Should we include ACL Roles
* @param int $contact_id
* ID of a contact to search for.
* @param int $group_id
* ID of a group to search for.
* @param bool $aclRoles
* Should we include ACL Roles.
*
* @return array - Array of assoc. arrays of ACL rules
* @static
......@@ -403,7 +405,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
$rule = new CRM_ACL_BAO_ACL();
$acl = self::getTableName();
$contact = CRM_Contact_BAO_Contact::getTableName();
$c2g = CRM_Contact_BAO_GroupContact::getTableName();
......@@ -447,8 +448,10 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/**
* Get all of the ACLs through ACL groups
*
* @param int $contact_id - ID of a contact to search for
* @param int $group_id - ID of a group to search for
* @param int $contact_id
* ID of a contact to search for.
* @param int $group_id
* ID of a group to search for.
*
* @return array - Array of assoc. arrays of ACL rules
* @static
......@@ -511,8 +514,10 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
/**
* Get all ACLs granted to a contact through all group memberships
*
* @param int $contact_id - The contact's ID
* @param boolean $aclRoles - Include ACL Roles?
* @param int $contact_id
* The contact's ID.
* @param bool $aclRoles
* Include ACL Roles?.
*
* @return array - Assoc array of ACL rules
* @static
......@@ -522,7 +527,6 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL {
$rule = new CRM_ACL_BAO_ACL();
$acl = self::getTableName();
$c2g = CRM_Contact_BAO_GroupContact::getTableName();
$group = CRM_Contact_BAO_Group::getTableName();
......@@ -556,7 +560,8 @@ SELECT $acl.*
* Get all of the ACLs for a contact through ACL groups owned by Contact
* groups.
*
* @param int $contact_id - ID of a contact to search for
* @param int $contact_id
* ID of a contact to search for.
*
* @return array - Array of assoc. arrays of ACL rules
* @static
......@@ -569,7 +574,6 @@ SELECT $acl.*
$acl = self::getTableName();
$aclRole = 'civicrm_acl_role';
$aclER = CRM_ACL_DAO_EntityRole::getTableName();
$c2g = CRM_Contact_BAO_GroupContact::getTableName();
$group = CRM_Contact_BAO_Group::getTableName();
......@@ -628,7 +632,8 @@ SELECT $acl.*
/**
* Get all ACLs owned by a given contact, including domain and group-level.
*
* @param int $contact_id - The contact ID
* @param int $contact_id
* The contact ID.
*
* @return array - Assoc array of ACL rules
* @static
......@@ -668,8 +673,10 @@ SELECT $acl.*
/**
* Update the is_active flag in the db
*
* @param int $id id of the database record
* @param boolean $is_active value we want to set the is_active field
* @param int $id
* Id of the database record.
* @param bool $is_active
* Value we want to set the is_active field.
*
* @return Object DAO object on sucess, null otherwise
* @static
......@@ -698,7 +705,6 @@ SELECT $acl.*
return FALSE;
}
$query = "
SELECT count( a.id )
FROM civicrm_acl_cache c, civicrm_acl a
......@@ -846,10 +852,11 @@ SELECT g.*
*
* @return array
*/
public static function group($type,
$contactID = NULL,
$tableName = 'civicrm_saved_search',
$allGroups = NULL,
public static function group(
$type,
$contactID = NULL,
$tableName = 'civicrm_saved_search',
$allGroups = NULL,
$includedGroups = NULL
) {
......@@ -957,7 +964,8 @@ ORDER BY a.object_id
/**
* Delete ACL records
*
* @param int $aclId ID of the ACL record to be deleted.
* @param int $aclId
* ID of the ACL record to be deleted.
*
* @static
*/
......
......@@ -75,8 +75,10 @@ class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole {
/**
* Update the is_active flag in the db
*
* @param int $id id of the database record
* @param boolean $is_active value we want to set the is_active field
* @param int $id
* Id of the database record.
* @param bool $is_active
* Value we want to set the is_active field.
*
* @return Object DAO object on sucess, null otherwise
* @static
......@@ -88,7 +90,8 @@ class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole {
/**
* Delete Entity Role records
*
* @param int $entityRoleId ID of the EntityRole record to be deleted.
* @param int $entityRoleId
* ID of the EntityRole record to be deleted.
*
* @static
*/
......
......@@ -154,7 +154,6 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form {
' ', TRUE
);
$label = ts('Role');
$role = array(
'-1' => ts('- select role -'),
......@@ -275,7 +274,6 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form {
// note this also resets any ACL cache
CRM_Core_BAO_Cache::deleteGroup('contact fields');
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_ACL_BAO_ACL::del($this->_id);
CRM_Core_Session::setStatus(ts('Selected ACL has been deleted.'), ts('Record Deleted'), 'success');
......
......@@ -93,9 +93,9 @@ SELECT object_table
array('</td><td>', '</td></tr><tr><td>')
);
$label = ts('Role');
$role = array('-1' => ts('- select role -'),
$role = array(
'-1' => ts('- select role -'),
'0' => ts('Everyone'),
) + CRM_Core_OptionGroup::values('acl_role');
$entityID = &$this->add('select', 'entity_id', $label, $role, TRUE);
......
......@@ -61,8 +61,6 @@ class CRM_ACL_Form_EntityRole extends CRM_Admin_Form {
$aclRoles, TRUE
);
$label = ts('Assigned to');
$group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::staticGroup(FALSE, 'Access');
$this->add('select', 'entity_id', $label, $group, TRUE, array('class' => 'crm-select2 huge'));
......
......@@ -44,7 +44,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
*
* @return void
*/
public function buildQuickForm( ) {
public function buildQuickForm() {
CRM_Utils_System::setTitle( 'Wordpress Access Control' );
......@@ -63,7 +63,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
$roleObj = $wp_roles->get_role($role);
if (!empty($roleObj->capabilities)) {
foreach ($roleObj->capabilities as $ckey => $cname) {
if (array_key_exists($ckey , $permissionsArray)) {
if (array_key_exists($ckey, $permissionsArray)) {
$elementName = $role.'['.$ckey.']';
$defaults[$elementName] = 1;
}
......@@ -74,7 +74,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
$rolePerms[$role] = $permissionsArray;
foreach ( $rolePerms[$role] as $key => $value) {
$elementName = $role.'['.$key.']';
$this->add('checkbox' , $elementName , $value);
$this->add('checkbox', $elementName, $value);
}
$roles[$role] = $name;
}
......@@ -87,11 +87,11 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
$this->addButtons(
array(
array (
array(
'type' => 'next',
'name' => ts('Save'),
'spacing' => '',
'isDefault' => false ),
'isDefault' => FALSE ),
)
);
......@@ -131,7 +131,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
if ($role == 'anonymous_user') {
// Get the permissions into a format that matches what we get from WP
$allWarningPermissions = CRM_Core_Permission::getAnonymousPermissionsWarnings();
foreach ($allWarningPermissions as $key => $permission) {
foreach ($allWarningPermissions as $key => $permission) {
$allWarningPermissions[$key] = CRM_utils_String::munge(strtolower($permission));
}
$warningPermissions = array_intersect($allWarningPermissions, array_keys($rolePermissions));
......
......@@ -120,7 +120,8 @@ class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic {
);
// set breadcrumb to append to admin/access
$breadCrumb = array(array('title' => ts('Access Control'),
$breadCrumb = array(array(
'title' => ts('Access Control'),
'url' => CRM_Utils_System::url('civicrm/admin/access',
'reset=1'
),
......@@ -170,17 +171,21 @@ ORDER BY entity_id
$roles = CRM_Core_OptionGroup::values('acl_role');
$group = array('-1' => ts('- select -'),
$group = array(
'-1' => ts('- select -'),
'0' => ts('All Groups'),
) + CRM_Core_PseudoConstant::group();
$customGroup = array('-1' => ts('- select -'),
$customGroup = array(
'-1' => ts('- select -'),
'0' => ts('All Custom Groups'),
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
$ufGroup = array('-1' => ts('- select -'),
$ufGroup = array(
'-1' => ts('- select -'),
'0' => ts('All Profiles'),
) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
$event = array('-1' => ts('- select -'),
$event = array(
'-1' => ts('- select -'),
'0' => ts('All Events'),
) + CRM_Event_PseudoConstant::event();
......@@ -194,7 +199,6 @@ ORDER BY entity_id
$acl[$dao->id]['object_id'] = $dao->object_id;
$acl[$dao->id]['is_active'] = $dao->is_active;
if ($acl[$dao->id]['entity_id']) {
$acl[$dao->id]['entity'] = $roles[$acl[$dao->id]['entity_id']];
}
......
......@@ -108,7 +108,8 @@ class CRM_ACL_Page_ACLBasic extends CRM_Core_Page_Basic {
);
// set breadcrumb to append to admin/access
$breadCrumb = array(array('title' => ts('Access Control'),
$breadCrumb = array(array(
'title' => ts('Access Control'),
'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'),
));
CRM_Utils_System::appendBreadCrumb($breadCrumb);
......
......@@ -120,7 +120,8 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic {
);
// set breadcrumb to append to admin/access
$breadCrumb = array(array('title' => ts('Access Control'),
$breadCrumb = array(array(
'title' => ts('Access Control'),
'url' => CRM_Utils_System::url('civicrm/admin/access',
'reset=1'
),
......
This diff is collapsed.
......@@ -49,7 +49,8 @@ class CRM_Activity_BAO_ActivityAssignment extends CRM_Activity_DAO_ActivityConta
/**
* Add activity assignment.
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
* @return object activity type of object that is added
*/
......@@ -100,9 +101,12 @@ AND civicrm_contact.is_deleted = 0
/**
* Retrieve assignee names by activity_id
*
* @param array $activityIDs IDs of the activities
* @param boolean $isDisplayName if set returns display names of assignees
* @param boolean $skipDetails if false returns all details of assignee contact.
* @param array $activityIDs
* IDs of the activities.
* @param bool $isDisplayName
* If set returns display names of assignees.
* @param bool $skipDetails
* If false returns all details of assignee contact.
*
* @return array
*
......
......@@ -49,7 +49,8 @@ class CRM_Activity_BAO_ActivityContact extends CRM_Activity_DAO_ActivityContact
/**
* Funtion to add activity contact
*
* @param array $params the values for this table: activity id, contact id, record type
* @param array $params
* The values for this table: activity id, contact id, record type.
*
* @return object activity_contact object
*
......
......@@ -47,7 +47,8 @@ class CRM_Activity_BAO_ICalendar {
/**
* Constructor
*
* @param object $act Reference to an activity object
* @param object $act
* Reference to an activity object.
*
* @return \CRM_Activity_BAO_ICalendar
@access public
......@@ -59,8 +60,10 @@ class CRM_Activity_BAO_ICalendar {
/**
* Add an ics attachment to the input array
*
* @param array $attachments Reference to array in same format returned from CRM_Core_BAO_File::getEntityFile()
* @param array $contacts Array of contacts (attendees)
* @param array $attachments
* Reference to array in same format returned from CRM_Core_BAO_File::getEntityFile().
* @param array $contacts
* Array of contacts (attendees).
*
* @return string Array index of the added attachment in the $attachments array, or else null.
*/
......
......@@ -433,7 +433,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
$urlString = 'civicrm/contact/search/advanced';
}
elseif ($path == 'civicrm/group/search'
|| $path == 'civicrm/contact/search'
|| $path == 'civicrm/contact/search'
|| $path == 'civicrm/contact/search/advanced'
|| $path == 'civicrm/contact/search/custom'
|| $path == 'civicrm/group/search') {
......@@ -677,7 +677,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
CRM_Campaign_BAO_Campaign::accessCampaign()
) {
$buildEngagementLevel = TRUE;
$this->addSelect('engagement_level',array('entity' => 'activity'));